Open Closed

Separate Tenant DB's without the IMultiTenancy interface #2411


User avatar
0
Spospisil created
  • ABP Framework version: v4.4.4
  • UI type: MVC
  • DB provider: EF Core
  • Tiered (MVC) or Identity Server Separated (Angular): Tiered/Identity Server

I have separate DB's for each tenant in our solution. We are migrating legacy data for each tenant and do not wish to use the TenantID (Guid) that comes along with using the IMultiTenancy interface on our domain classes used to map to our DB tables. However if we don't implement this interface on our domain class the EFCoreRepository class changes the current tenant to null before getting the connection string, so as a result it gets the host connection string and not the tenant's connection string.

How do I do this?


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

    Hi,

    This is the design of a multi-tenant system, I'm sorry to tell you that you can't change it.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    If you use a separate database for each tenant, you can remove the IMultiTenant

  • User Avatar
    0
    balessi75 created

    Hi Spospisil, I had ran into the exact same problem, but was forced to implement IMultiTenancy even with separate databases for each tenant. I am using version 4.4.3 though.

    Are you still running into this issue?

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    If the entity is not multi-tenant, then it will always switch to host

    See https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.EntityFrameworkCore/Volo/Abp/Domain/Repositories/EntityFrameworkCore/EfCoreRepository.cs#L39

    You can custom your own repository base and override GetDbContext and GetDbContextAsync methods.

    See https://docs.abp.io/en/abp/latest/Entity-Framework-Core#set-default-repository-classes

Made with ❤️ on ABP v9.1.0-preview. Updated on November 20, 2024, 13:06