Open Closed

Context instance being disposed in background job #4810


User avatar
0
pablo@ccalp.net created
  • ABP Framework version: v7.0
  • UI type: Angular
  • DB provider: EF Core

I want to implement a background job using the framework (abp) default implementation. I created a Domain service and I'm passing the tenantid as a parameter and then changing the CurrentTenant. I'm also getting the DbContext from the repository to query the database, but getting an exception saying that it cannot access a disposed context. What is the right approach to be able to create multitenant aware background jobs? I would need to get the user ingo that submitted the job too.


1 Answer(s)
  • User Avatar
    0
    salih created
    Support Team .NET Developer

    Hi, I recommend you to use unit of work when you get error about Context dispose. You can review the document. My suggestion is to use IUnitOfWorkManager. https://docs.abp.io/en/abp/latest/Unit-Of-Work#iunitofworkmanager

Made with ❤️ on ABP v8.2.0-preview Updated on March 25, 2024, 15:11