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.

Markdown supported.
Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)

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

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
Boost Your Development
ABP Live Training
Packages
See Trainings
Mastering ABP Framework Book
The Official Guide
Mastering
ABP Framework
Learn More
Mastering ABP Framework Book
Made with ❤️ on ABP v10.8.0-preview. Updated on September 16, 2026, 14:50
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.