Open Closed

MultiTenant ConnectionString property doesn't work #6261


User avatar
0
cetin.sahin created
  • ABP Framework version: v7.3.4
  • UI Type: Blazor Server
  • Database System: EF Core (SQL Server
    • Tiered (for MVC) or Auth Server Separated (for Angular): yes
  • Exception message and full stack trace:
  • Steps to reproduce the issue:

we add this code to all configuresservices

Configure<AbpMultiTenancyOptions>(options =>
{
    options.IsEnabled = MultiTenancyConsts.IsEnabled;
});

and we Replace Services MultiTenantConnectionStringResolver with https://github.com/abpframework/abp/blob/dev/framework/src/Volo.Abp.MultiTenancy/Volo/Abp/MultiTenancy/MultiTenantConnectionStringResolver.cs

and we add connection string to tenant configuration(Test Tenant)

But we login with test tenant with special connection string but abp loaded to grid with data to default connection(Host) string database

MultiTenant ConnectionString property doesn't work.


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

    Can you share a test project? I will check it.

    My email is shiwei.liang@volosoft.com

  • User Avatar
    0
    cetin.sahin created

    Of course I sent MultitenantTest.rar via We transfer.

  • User Avatar
    0
    cetin.sahin created

    We want to Multi tenant project only database level not table level.

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    The Deneme entity have to implement IMultiTenant interface.

    This is a convention, otherwise, the APB framework will use it as a host entity

  • User Avatar
    0
    cetin.sahin created

    But we already use different db by tenant. why do we implement entity IMultiTenant interface

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    Hi,

    Yes, this is a design. Suppose you want to create an entity as a host entity,, what should you do. Some tenants use separate databases, and some tenants use shared databases., How to filter the data.

    IMultiTenant interface is an identifier used to indicate that the entity is a multi-tenant entity, It is designed for the above scenarios.

  • User Avatar
    0
    cetin.sahin created

    How can We change from tenantId (Guid) to KurumId(int). We must use exist old mssql db.(db first)

  • User Avatar
    0
    liangshiwei created
    Support Team Fullstack Developer

    How can We change from tenantId (Guid) to KurumId(int).

    Sorry, it's not possible. see: https://github.com/abpframework/abp/issues/1704#issuecomment-527372545

    You can consider to add a new property type as KurumId(int), then use it as your business primary key:

    ObjectExtensionManager.Instance
        .MapEfCoreProperty<Tenant, int>(
            "KurumId",
            (entityBuilder, propertyBuilder) =>
            {
                propertyBuilder.HasIndex()
                               .IsUnique();
            }
        );
    
Made with ❤️ on ABP v9.1.0-preview. Updated on November 11, 2024, 11:11