Open Closed

How do I setup per-schema multi-tenancy with SQL Server #5083


User avatar
0
rick@dripjobs.com created

From the tooling, when I choose schema per Tenant, it creates tables called App[EntityName] with a TenantId column vs putting the tables in a schema prefix? Am I missing something in the instructions and or tooling to achieve this or is it not supported?


1 Answer(s)
  • User Avatar
    0
    maliming created
    Support Team Fullstack Developer

    hi

    Separate tenant schema is means:

    This solution configured so it uses two database schema;

    • Default schema is used to store host & tenant data (when the tenant uses shared database).
    • Tenant schema is used to store only the tenant data (when the tenant uses a dedicated database).

    In this way, dedicated tenant databases do not have host-related empty tables.

    To make this possible, there are two migrations DbContext in the EntityFrameworkCore project. So, you need to specify the DbContext when you want to add new migration.

    When you add/change a multi-tenant entity (that implements IMultiTenant) in your project, you typically need to add two migrations: one for the default DbContext and the other one is for the tenant DbContext. If you are making change for a host-only entity, then you don't need to add-migration for the tenant DbContext (if you add, you will get an empty migration file).

Made with ❤️ on ABP v9.1.0-preview. Updated on December 10, 2024, 06:38