EntityFramework's dbContext started throwing an EntityCommandCompilationException
See original GitHub issueSuddenly every usage of ef started throwing the following exception:
System.Data.Entity.Core.EntityCommandCompilationException: An error occurred while preparing the command definition. See the inner exception for details.\r\n ---> System.InvalidOperationException: Operations that change non-concurrent collections must have exclusive access. A concurrent update was performed on this collection and corrupted its state. The collection's state is no longer correct.\r\n at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)\r\n at System.Data.Entity.Core.Query.InternalTrees.BitVec.ArrayPool.GetBag(Int32 length)\r\n at System.Data.Entity.Core.Query.InternalTrees.BitVec.ArrayPool.GetArray(Int32 length)\r\n at System.Data.Entity.Core.Query.InternalTrees.BitVec..ctor(Int32 length, Boolean defaultValue)\r\n at System.Data.Entity.Core.Query.InternalTrees.Command.CreateVarVec()\r\n at System.Data.Entity.Core.Query.InternalTrees.Table..ctor(Command command, TableMD tableMetadata, Int32 tableId)\r\n at System.Data.Entity.Core.Query.InternalTrees.Command.CreateTableInstance(TableMD tableMetadata)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.Visit(DbScanExpression e)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.VisitBoundExpression(DbExpression boundExpression, Var& boundVar)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.EnterExpressionBinding(DbExpressionBinding binding)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.Visit(DbFilterExpression e)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.VisitBoundExpression(DbExpression boundExpression, Var& boundVar)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.EnterExpressionBinding(DbExpressionBinding binding)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.GenerateStandardProject(DbProjectExpression e)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator.Visit(DbLimitExpression expression)\r\n at System.Data.Entity.Core.Query.PlanCompiler.ITreeGenerator..ctor(DbQueryCommandTree ctree, DiscriminatorMap discriminatorMap)\r\n at System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Initialize()\r\n at System.Data.Entity.Core.Query.PlanCompiler.PlanCompiler.Compile(List`1& providerCommands, ColumnMap& resultColumnMap, Int32& columnCount, Set`1& entitySets)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory)\r\n --- End of inner exception stack trace ---\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityCommandDefinition..ctor(DbProviderFactory storeProviderFactory, DbCommandTree commandTree, DbInterceptionContext interceptionContext, IDbDependencyResolver resolver, BridgeDataReaderFactory bridgeDataReaderFactory, ColumnMapFactory columnMapFactory)\r\n at System.Data.Entity.Core.EntityClient.Internal.EntityProviderServices.CreateDbCommandDefinition(DbProviderManifest providerManifest, DbCommandTree commandTree, DbInterceptionContext interceptionContext)\r\n at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.CreateCommandDefinition(ObjectContext context, DbQueryCommandTree tree)\r\n at System.Data.Entity.Core.Objects.Internal.ObjectQueryExecutionPlanFactory.Prepare(ObjectContext context, DbQueryCommandTree tree, Type elementType, MergeOption mergeOption, Boolean streaming, Span span, IEnumerable`1 compiledQueryParameters, AliasGenerator aliasGenerator)\r\n at System.Data.Entity.Core.Objects.ELinq.ELinqQueryState.GetExecutionPlan(Nullable`1 forMergeOption)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass43_0.<GetResultsAsync>b__1()\r\n at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransactionAsync[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess, CancellationToken cancellationToken)\r\n at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.ExecuteAsyncImplementation[TResult](Func`1 func)\r\n at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResultsAsync(Nullable`1 forMergeOption, IDbExecutionStrategy executionStrategy, CancellationToken cancellationToken)\r\n at System.Data.Entity.Internal.LazyAsyncEnumerator`1.FirstMoveNextAsync(CancellationToken cancellationToken)\r\n at System.Data.Entity.Infrastructure.IDbAsyncEnumerableExtensions.SingleOrDefaultAsync[TSource](IDbAsyncEnumerable`1 source, CancellationToken cancellationToken)\r\n at XFront.ServerCodes.Implementations.XFrontDeviceIdStaffIdCompanyIdManagementMiddleware.ManageStaffIdDeviceIdCompanyId(IOwinContext context)\r\n at XFront.ServerCodes.Implementations.XFrontDeviceIdStaffIdCompanyIdManagementMiddleware.Invoke(IOwinContext context)\r\n at Microsoft.Owin.Mapping.MapMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.Owin.Mapping.MapMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.Owin.Mapping.MapMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.Owin.Mapping.MapMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.Owin.Mapping.MapMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.Owin.Mapping.MapMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.Owin.Mapping.MapWhenMiddleware.Invoke(IDictionary`2 environment)\r\n at Microsoft.AspNetCore.Owin.WebSocketAcceptAdapter.<>c__DisplayClass6_0.<<AdaptWebSockets>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Microsoft.Owin.Security.Infrastructure.AuthenticationMiddleware`1.Invoke(IOwinContext context)\r\n at Microsoft.AspNetCore.Owin.WebSocketAcceptAdapter.<>c__DisplayClass6_0.<<AdaptWebSockets>b__0>d.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at Bit.OwinCore.Middlewares.AspNetCoreExceptionHandlerMiddleware.Invoke(HttpContext context)",
"ExceptionAdditionalMessage": "Request-Execution-Exception",
"ExceptionType": "System.Data.Entity.Core.EntityCommandCompilationException",
"ExceptionTypeAssemblyQualifiedName": "System.Data.Entity.Core.EntityCommandCompilationException, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
}
Steps to reproduce
N/A
Further technical details
EF version: 6.3.0-preview8-19405-04 Database Provider: EntityFramework.SqlServer Operating system: Microsoft Windows NT 10.0.17763.0 X64 IDE: VS 16.2.2 .NET Core 3.0.0-preview8-28405-07
Restarting IIS/App resolved the issue.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:2
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Stack Overflow
1 · Your database is throwing an exception on the query that EF is trying to run to select your models. · @sstan,...
Read more >EntityCommandExecutionExcepti...
Represents errors that occur when the underlying storage provider could not execute the specified command. This exception usually wraps a provider-specific ...
Read more >Interceptors - EF Core
Entity Framework Core (EF Core) interceptors enable interception, modification, and/or suppression of EF Core operations.
Read more >Entity Framework Core DbContext
Adds a new entity to DbContext with Added state and starts tracking it. This new entity data will be inserted into the database...
Read more >7.1 Entity Framework 6 Support
Starting with Entity Framework 6, Database.ExecuteSqlCommand() will wrap by default the command in a transaction if one was not already present. There are ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
When will this be deployed?
Daily builds are available to test now. Use version 6.3.0-rc2-*