ralmsdeveloper / EntityFrameworkCore.FirebirdSQL

FirebirdSQL database provider for Entity Framework Core.
Other
44 stars 26 forks source link

NullRefException in EntityFrameworkCore.FirebirdSql.Query.Sql.Internal.FbQuerySqlGenerator..ctor #45

Closed krilbe closed 5 years ago

krilbe commented 5 years ago

The issue

Only on our server (Staging) not in devenv (Development) we get a NullReferenceException in the FbQuerySqlGenerator constructor.

Steps to reproduce

We are unable at this time to produce a valid test case, but it happens on a line like this: DbSet<Document> docs = dbContext.Document, where Document is a model class. We have checked that the database connection is ok, that dbContext is not null and that dbContext.Document is not null. Strangely we can evaluate dbContext.Document?.ToString() without problem, but not DbSet<Document> docs = dbContext.Document or var docs = dbContext.Document.

Error details

Exception message: Object reference not set to an instance of an object.
Stack trace:
   at EntityFrameworkCore.FirebirdSql.Query.Sql.Internal.FbQuerySqlGenerator..ctor(QuerySqlGeneratorDependencies dependencies, SelectExpression selectExpression, IFbOptions fBOptions)
   at EntityFrameworkCore.FirebirdSql.Query.Sql.Internal.FbQuerySqlGeneratorFactory.CreateDefault(SelectExpression selectExpression)
   at Microsoft.EntityFrameworkCore.Query.Expressions.SelectExpression.CreateDefaultQuerySqlGenerator()
   at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.<NotifyReaderCreated>b__14_0(FactoryAndReader s)
   at Microsoft.EntityFrameworkCore.Internal.NonCapturingLazyInitializer.EnsureInitialized[TParam,TValue](TValue& target, TParam param, Func`2 valueFactory)
   at Microsoft.EntityFrameworkCore.Query.Internal.ShaperCommandContext.NotifyReaderCreated(DbDataReader dataReader)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
   at Microsoft.EntityFrameworkCore.Storage.Internal.NoopExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.QueryMethodProvider.GetResult[TResult](IEnumerable`1 valueBuffers, Boolean throwOnNullResult)
   at lambda_method(Closure )
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable`1.GetEnumerator()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.<>c__DisplayClass15_1`1.<CompileQueryCore>b__0(QueryContext qc)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.Execute[TResult](Expression query)
   at Microsoft.EntityFrameworkCore.Query.Internal.EntityQueryProvider.Execute[TResult](Expression expression)
   at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
   at [our code]

Further technical details

Firebird version: 3.0.3 (Windows 64 bit) EntityFrameworkCore.FirebirdSql version: 2.1.2.2

Other details about my project setup: The project is DotNetCore 2.1.

krilbe commented 5 years ago

I cloned the repo to do some tests and the problem seems to vanish with latest source (2.1.4). So, this issue would be a duplicate of #42 apparently. Sorry for not reading thoroughly...

ralmsdeveloper commented 5 years ago

All, well sorry for the delay, I'm going back to work.