How could i create a seed to insert default data to the last created Db with multi tenancy?. or should I use any other method to insert default data..?
I need to insert some data to new Db at the time when i create new tenancy.I have created a seed method with tenant Id 1, as described in sample application. but it not works for me,the data are inserted into main Db only.
3 Answer(s)
-
0
If you used module-zero template and using db per tenant approach, you can seed it here: <a class="postlink" href="https://github.com/aspnetboilerplate/module-zero-template/blob/master/src/AbpCompanyName.AbpProjectName.EntityFramework/Migrations/Configuration.cs#L34">https://github.com/aspnetboilerplate/mo ... ion.cs#L34</a>
Another option is just adding data using repositories just after creating the tenant.
-
0
thanks for the help, but one more problem is i couldn't insert new created tenant Id to the table with seed data before login.
-
0
Hi,
Instead of seed method you can create a custom class, TenantDefaultDataCreator for example, and call it in CreateTenant method of TenantAppService. If you think it will take a long time, you can do it with background jobs.