Liquid-Application-Framework icon indicating copy to clipboard operation
Liquid-Application-Framework copied to clipboard

Exception thrown from worker when executing generic crud command

Open karpikpl opened this issue 2 years ago • 0 comments

Exception:

fail: Liquid.Core.Implementations.LiquidTelemetryInterceptor[0] Execution of UpdateAsync from Liquid.Repository.EntityFramework.EntityFrameworkRepository3[[Properties.Domain.Entities.Property, Properties.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Properties.Repository.PropertiesDbContext, Properties.Repository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] has thrown an exception. System.ObjectDisposedException: Cannot access a disposed context instance. A common cause of this error is disposing a context instance that was resolved from dependency injection and then later trying to use the same context instance elsewhere in your application. This may occur if you are calling 'Dispose' on the context instance, or wrapping it in a using statement. If you are using dependency injection, you should let the dependency injection container take care of disposing context instances. Object name: 'PropertiesDbContext'. at Microsoft.EntityFrameworkCore.DbContext.CheckDisposed() at Microsoft.EntityFrameworkCore.DbContext.get_DbContextDependencies() at Microsoft.EntityFrameworkCore.DbContext.SaveChangesAsync(Boolean acceptAllChangesOnSuccess, CancellationToken cancellationToken) at Liquid.Repository.EntityFramework.EntityFrameworkRepository3.UpdateAsync(TEntity entity) at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous(IInvocation invocation, IInvocationProceedInfo proceedInfo) at Liquid.Core.Base.LiquidInterceptorBase.InterceptAsync(IInvocation invocation, IInvocationProceedInfo proceedInfo, Func3 proceed) Liquid.Core.Implementations.LiquidTelemetryInterceptor: Error: Execution of UpdateAsync from Liquid.Repository.EntityFramework.EntityFrameworkRepository3[[Properties.Domain.Entities.Property, Properties.Domain, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null],[System.Int64, System.Private.CoreLib, Version=5.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e],[Properties.Repository.PropertiesDbContext, Properties.Repository, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]] has thrown an exception.

Command throwing it from implementation of ILiquidWorker

 var updateResponse = await _mediator.Send(new UpdateGenericEntityCommand<Property, long>(property));

In 1Program.cs` repositories are registered:

services.RegisterCrud<Property, long>();
services.AddLiquidEntityFramework<PropertiesDbContext, Property, long>(options);

karpikpl avatar Mar 07 '22 02:03 karpikpl