Base solution for your next web application
Ends in:
01 DAYS
01 HRS
01 MIN
01 SEC
Open Closed

TenantId assignment - Is the logic working in reverse here? #10180


User avatar
0
fatih.ozturk created

Hello,

I am confused about the TenantId assignment. If MultiTenancyEnabled = true, TenantId is assigned null. Is that correct usage?

namespace XDemo.Migrations.Seed.Host { public class DefaultLanguagesCreator { public static List InitialLanguages => GetInitialLanguages();

private readonly XDemoDbContext _context;

private static List<ApplicationLanguage> GetInitialLanguages() {     var tenantId = XDemoConsts.MultiTenancyEnabled ? null : (int?)1;

...

public class XDemoConsts { public const string LocalizationSourceName = "XDemo";

public const string ConnectionStringName = "Default";

public const bool MultiTenancyEnabled = true; ...

I was excepting if MultiTenancyEnabled is true then an Id should be assigned to the tenants such as:

var tenantId = XDemoConsts.MultiTenancyEnabled ? (int?)1 : null ;

Kind regards


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

    Hi @fatih.ozturk

    When the MultiTenancy is enabled, TenantId=null represents the Host. So, in that case, soem data will be created by Host and it will be used by all tenants.

    In this specific case, Languages will be created for Host, and will be used by all Tenants.

    But, when MultiTenancy is disabled, there will be no Host, so data will be created for default tenant (TenantId=1).