Hello,
I'm trying to migrate one of our applications to the beta1 of EFCore provider and have problem if change the minimum logging level.
To try to reproduce the error in clean project I took the example from
https://github.com/cincuranet/FirebirdSql.Data.FirebirdClient/blob/master/docs/entity-framework-core.md and
and just changed the minimum log level in line:
static readonly ILoggerFactory MyLoggerFactory = LoggerFactory.Create(builder => { builder.AddConsole(); builder.SetMinimumLevel(LogLevel.Trace); });I receive the error 'Object reference not set to an instance of an object.' and it occured in
public override string Database
{
get { return _options.Database; }
}The get is invoked from ConnectionDisposed in RelationalConnectionDiagnosticsLogger when is logging the disposal of the context:
definition.Log(this, connection.DbConnection.Database, connection.DbConnection.DataSource, (int)duration.TotalMilliseconds);
But this is after the Dispose method of FBConnection is called and the _options is set to null
If I set the level to Warning - it does not throw error. Only if is set to Trace or Debug
the stack trace is:
FirebirdSql.Data.FirebirdClient.dll!FirebirdSql.Data.FirebirdClient.FbConnection.Database.get() Line 205 C#
Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Diagnostics.Internal.RelationalConnectionDiagnosticsLogger.ConnectionDisposed(Microsoft.EntityFrameworkCore.Storage.IRelationalConnection connection, System.DateTimeOffset startTime, System.TimeSpan duration) Line 668 C#
Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Storage.RelationalConnection.DisposeDbConnection() Line 1113 C#
Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Storage.RelationalConnection.ResetState(bool disposeDbConnection) Line 1047 C#
Microsoft.EntityFrameworkCore.Relational.dll!Microsoft.EntityFrameworkCore.Storage.RelationalConnection.Dispose() Line 1014 C#
Microsoft.Extensions.DependencyInjection.dll!Microsoft.Extensions.DependencyInjection.ServiceLookup.ServiceProviderEngineScope.Dispose() Line 104 C#
Microsoft.EntityFrameworkCore.dll!Microsoft.EntityFrameworkCore.DbContext.Dispose() Line 1058 C#
ConsoleApp2.dll!Program.Main(string[] args) Line 12 C#