Base solution for your next web application
Open Closed

Multi Tenancy - DbContexts connection strings #1695


User avatar
0
jboliveira created

Hi,

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,

jboliveira


1 Answer(s)
  • User Avatar
    0
    ismcagdas created
    Support Team

    Hi,

    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="http://aspnetboilerplate.com/Pages/Documents/Multi-Tenancy">http://aspnetboilerplate.com/Pages/Docu ... ti-Tenancy</a>.