HackSystem icon indicating copy to clipboard operation
HackSystem copied to clipboard

A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext.

Open CuteLeon opened this issue 4 years ago • 0 comments

2021-08-07 02:03:03.4370 10000 ERROR Microsoft.EntityFrameworkCore.Update An exception occurred in the database while saving changes for context type 'HackSystem.WebAPI.DataAccess.HackSystemDBContext'. System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913. at Microsoft.EntityFrameworkCore.Infrastructure.Internal.ConcurrencyDetector.EnterCriticalSection() in Microsoft.EntityFrameworkCore.dll:token 0x6001bbd+0x26 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList1 entriesToSave, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x60024ca+0x11 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x60024ce+0xc7 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x6000092+0x171 System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913. at Microsoft.EntityFrameworkCore.Infrastructure.Internal.ConcurrencyDetector.EnterCriticalSection() in Microsoft.EntityFrameworkCore.dll:token 0x6001bbd+0x26 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList1 entriesToSave, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x60024ca+0x11 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x60024ce+0xc7 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x6000092+0x171 2021-08-07 02:03:03.4370 1 ERROR Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware An unhandled exception has occurred while executing the request. System.InvalidOperationException: A second operation was started on this context instance before a previous operation completed. This is usually caused by different threads concurrently using the same instance of DbContext. For more information on how to avoid threading issues with DbContext, see https://go.microsoft.com/fwlink/?linkid=2097913. at Microsoft.EntityFrameworkCore.Infrastructure.Internal.ConcurrencyDetector.EnterCriticalSection() in Microsoft.EntityFrameworkCore.dll:token 0x6001bbd+0x26 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(IList1 entriesToSave, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x60024ca+0x11 at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.SaveChangesAsync(StateManager stateManager, Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x60024ce+0xc7 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x6000092+0x171 at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) in Microsoft.EntityFrameworkCore.dll:token 0x6000092+0x3f1 at HackSystem.WebAPI.DataAccess.DataServices.DataServiceBase1.AddAsync(TEntity entity) in E:\GitHub\HackSystem\HackSystem.WebAPI.DataAccess\DataServices\DataServiceBase.cs:line 37 at HackSystem.WebAPI.Extensions.WebAPILogs.Middleware.WebAPILoggingMiddleware.Invoke(HttpContext context) in E:\GitHub\HackSystem\HackSystem.WebAPI.Extensions\WebAPILogs\Middlewares\WebAPILoggingMiddleware.cs:line 60 at Microsoft.AspNetCore.Authorization.AuthorizationMiddleware.Invoke(HttpContext context) in Microsoft.AspNetCore.Authorization.Policy.dll:token 0x600000b+0x16b at Microsoft.AspNetCore.Authentication.AuthenticationMiddleware.Invoke(HttpContext context) in Microsoft.AspNetCore.Authentication.dll:token 0x6000044+0x384 at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware.Invoke(HttpContext context) in Microsoft.AspNetCore.Diagnostics.dll:token 0x60000aa+0x82

CuteLeon avatar Aug 06 '21 18:08 CuteLeon