Open Closed

DBContext for tenants #246


User avatar
0
chanchai-mwp created
  • ABP Framework version: v2.9.0
  • UI type: Angular
  • Tiered (MVC) or Identity Server Seperated (Angular): yes

NetZero:

using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.Suppress)) {
using (var dbContext = _dbContextResolver.Resolve<Project1DemoDbContext>(connectionString, null)) { } }

AbpCommercial

How can we get dbcontext for tenants that have different connectionsstrings like NetZero.

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

4 Answer(s)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    Try:

    using (CurrentTenant.Change(Guid.Parse("tenant id")))
    {
        var dbContext= await _repository.GetDbContext();
    }
    

    See https://docs.abp.io/en/abp/latest/Entity-Framework-Core#access-to-the-ef-core-api

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    chanchai-mwp created

    No luck. Couldn't find .GetDbContext() here.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    Hi,

    You need add Volo.Abp.EntityframeworkCore NuGet package to your project.

    Markdown supported.
    Copy, paste, or drag & drop images and files (max 100 MB per file, 100 MB total per post)
  • User Avatar
    0
    liangshiwei created
    Fullstack Developer

    I close this question, If you still have this question, Please reopen.

    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 28, 2026, 11:44
1
ABP Assistant
🔐 You need to be logged in to use the chatbot. Please log in first.