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)
-
0
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
).