Output generated SQL from Entity Framework to the console
dotnet add [project_file.csproj] package Microsoft.Extensions.Logging.Console
public static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => {builder.AddConsole();});
...
services.AddDbContext(o => {
o.UseSqlServer(connection, options => options.EnableRetryOnFailure())
.UseLoggerFactory(MyLoggerFactory);
})
...
DB Context is null when being injected into a Repository class
Fields in appsettings.json must have a correspdoning property in AppSettings.cs in order to be available in code.