Open Closed

Multi Tenancy - DbContexts connection strings #1695

jboliveira created


I'm not fully understanding something about the multi tenancy db contexts. Follow my current situation:

  • Host (Contains all core tables + ABP + Zero Tables) ---- Separeted database/context
  • Tenants ---- Each tenant has a different database to store the data (so, different connection strings) with the same structure/context

So, when you login, the api should be able to capture the Tenant connection string and set it for the TenantDbContext.

The point is, Im trying to create this scenario, but Im not understanding how could I config it, or how could capture the connection string and transfer to my context dynamically.

Thanks for any help,


1 Answer(s)
  • 0
    ismcagdas created
    Support Team


    You just need to set tenantId of your current unitOfWork. ABP handles the rest. See the section "Switching Between Host and Tenants" of this document <a class="postlink" href=""> ... ti-Tenancy</a>.