Hi guys,
I struggle a little bit to understand methodoly of creating a new tenant in "Single Deployment - Multiple Database".
I would like to create default DB for host (managing editions/tenants), and a sub DB foreach tenant (different connection string).
regarding this code
if (Tenant == null)
{
//Host seed
new InitialHostDbBuilder(context).Create();
//Default tenant seed (in host database).
new DefaultTenantBuilder(context).Create();
new TenantRoleAndUserBuilder(context, 1).Create();
new InitialCustomDbBuilder(context).Create();
}
else
{
//new TenantRoleAndUserBuilder(context, Tenant.Id).Create();
//new InitialCustomDbBuilder(context).Create();
}
is the default tenant mandatory ? (even if we don't use it)
new DefaultTenantBuilder(context).Create();
new TenantRoleAndUserBuilder(context, 1).Create();
if the seed run into the else{} method (tenant creation, when we specify a connectionstring in dashboard), do we need to change the connectionstring with this method to set seed into the correct db ?
(_unitOfWorkManager.Current.SetTenantId(tenantId))
Thanks for your help! ;)
1 Answer(s)
-
0
Hi,
Yes, default tenant is required even if you don't use it (and it should be in host db). You can de-activate it if you don't want to use.
When you create tenant on UI, no need to this seed code, since TenantManager.Create method inserts new tenant data. You can add such a seed code if you like, but we don't prefer it.