Hi, GetAllIncluding gives exception "Cannot access disposed object..." in hangfire background job.
4 Answer(s)
-
0
Your
DbContext
might have been disposed! The reason for that can be lack of UnitOfWork. Show your background job file. -
0
Very similar: https://github.com/aspnetboilerplate/aspnetboilerplate/issues/3873
-
0
[UnitOfWork] //Added but not working public void InitiateNewWorkflow(int requestMainId, int requestTypeId) { var initialRequestConfiguration = _requestTypeConfigurationRepository.GetAllIncluding(p => p.InitialState).Where(p => p.RequestTypeId == requestTypeId);
...other code
}
// calling... var jobId = BackgroundJob.Enqueue(() => _workflowManager.InitiateNewWorkflow(requestMainId, requestTypeId.Value));
I have added [UnitOfWork] but its not working.
-
0
You can create a unit of work inside the InitiateNewWorkflow method.
using (var uow = _unitOfWorkManager.Begin()) { var initialRequestConfiguration = _requestTypeConfigurationRepository.GetAllIncluding(p => p.InitialState).Where(p => p.RequestTypeId == requestTypeId); ...other code }