Sorry for asking, couldn't find where I can write code to fill default data in some tables for tenant when new tenant is creating. Pls help.
4 Answer(s)
-
0
If you are asking for module zero startup template, then it's defined in TenantAppService. We are also filling some data when tenant is being created. See the code: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.Application/MultiTenancy/TenantAppService.cs#L72">https://github.com/aspnetboilerplate/mo ... ice.cs#L72</a>
-
0
Is this the same in case (a) Tenant is created manually from Host (b) Tenant is created by user from landing page?
-
0
Hi,
Both places use TenantManager's CreateWithAdminUserAsync method. You can do it in that method.
-
0
FYI, i created a console project to create multiple tenant at once.
my code look like this :
const string tenantConnectionString = "Data Source=XXXXXXXX;Integrated Security=False;User ID=XXXXXXXXX;Password=XXXXXXXX;Initial Catalog=XXXXXXXXX;"; var tenantId = _tenantManager.CreateWithAdminUserAsync("XXXXX", "XXXXXXX", "XXXXXXX", "xxxxxxxxxxx", xXXXXXX, true, null, false, false).Result; SeedXXXX(tenantId); protected void SeedXXXX(int tenantId) { using (var uow = _unitOfWorkManager.Begin(TransactionScopeOption.RequiresNew)) { using (_unitOfWorkManager.Current.SetTenantId(tenantId)) { var context = _unitOfWorkManager.Current.GetDbContext<XXXXXDbContext>(); new XXXXXXDbBuilder(context).Create(); _unitOfWorkManager.Current.SaveChanges(); } uow.Complete(); } }
yup, maybe I need to clean a little bit my code, i'm not yet a pro of unitofwork ;)