I am using a FullAuditedEntity in a background job. I need to save the entity several times in the process its a long running job. but I am getting exceptions due to concurrency stamp mismatch. I need to disable the concurrency stamp check built in the abp framework. How can I do this?
P.S. I am using mongodb.
I want to save the entity regardless of concurrency stamp check.
Volo.Abp.BackgroundJobs.BackgroundJobExecutionException (M24582:36032)
A background job execution is failed. See inner exception for details.
Volo.Abp.BackgroundJobs.BackgroundJobExecutionException: A background job execution is failed. See inner exception for details.
---> Volo.Abp.Data.AbpDbConcurrencyException: Database operation expected to affect 1 row but actually affected 0 row. Data may have been modified or deleted since entities were loaded. This exception has been thrown on optimistic concurrency check.
at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository`2.ThrowOptimisticConcurrencyException()
at Volo.Abp.Domain.Repositories.MongoDB.MongoDbRepository`2.UpdateAsync(TEntity entity, Boolean autoSave, CancellationToken cancellationToken)
at Castle.DynamicProxy.AsyncInterceptorBase.ProceedAsynchronous[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo)
at Volo.Abp.Castle.DynamicProxy.CastleAbpMethodInvocationAdapterWithReturnValue`1.ProceedAsync()
at Volo.Abp.Uow.UnitOfWorkInterceptor.InterceptAsync(IAbpMethodInvocation invocation)
at Volo.Abp.Castle.DynamicProxy.CastleAsyncAbpInterceptorAdapter`1.InterceptAsync[TResult](IInvocation invocation, IInvocationProceedInfo proceedInfo, Func`3 proceed)
at KissIM.ParasiteSEO.Main.TrafficThief.BackgorundJobs.CreateArticleBackgroundJob.ExecuteAsync(CreateArticleBackgroundJobArgs args) in D:OnlineTFSWebApps2023ParasiteSEOKissIM.ParasiteSEOaspnet-coresrcKissIM.ParasiteSEO.DomainMainTrafficThiefBackgorundJobsCreateArticleBackgroundJob.cs:line 46
at Volo.Abp.BackgroundJobs.BackgroundJobExecuter.ExecuteAsync(JobExecutionContext context)
--- End of inner exception stack trace ---
at Volo.Abp.BackgroundJobs.BackgroundJobExecuter.ExecuteAsync(JobExecutionContext context)
at Volo.Abp.BackgroundJobs.Hangfire.HangfireJobExecutionAdapter`1.ExecuteAsync(String queue, TArgs args, CancellationToken cancellationToken)
at InvokeStub_TaskAwaiter.GetResult(Object, Object, IntPtr*)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Nevermind I found a solution. I added overrides for CreateEntitiesFilterAsync and CreateEntityFilterAsync in MongoDbRepositories
protected override Task<FilterDefinition<Entity>> CreateEntitiesFilterAsync(IEnumerable<Entity> entities, bool withConcurrencyStamp = false)
{
return base.CreateEntitiesFilterAsync(entities, false);
}
protected override Task<FilterDefinition<Entity>> CreateEntityFilterAsync(Entity entity, bool withConcurrencyStamp = false,
string? concurrencyStamp = null)
{
return base.CreateEntityFilterAsync(entity, false, concurrencyStamp);
}