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

Create seed to insert data to latest Db in multitenancy #1605


User avatar
0
sison created

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)
  • User Avatar
    0
    hikalkan created
    Support Team

    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.

  • User Avatar
    0
    sison created

    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.

  • User Avatar
    0
    ismcagdas created
    Support Team

    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.