I want to seed some tenant related data when a Tenant is created.
This is where I think I should seed data :
protected override void Seed(EntityFramework.CORPACCOUNTINGDbContext context) { context.DisableAllFilters();
if (SeedMode == SeedMode.Host)
{
//Host seed
new InitialHostDbBuilder(context).Create();
//Default tenant seed (in host database).
new DefaultTenantBuilder(context).Create();
new TenantRoleAndUserBuilder(context, 1).Create();
}
else if(SeedMode == SeedMode.Tenant)
{
// Here is where I plan to seed the data.
}
context.SaveChanges();
}
But how do I get the tenant to insert data by Tenant
4 Answer(s)
-
0
It seems there is a gap here. We will solve the problem in a short time. Follow this issue: <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/207">https://github.com/aspnetzero/aspnet-zero/issues/207</a>
-
0
Thank You
-
0
Can you point me to the solution/Answer to your question. I need to seed newly created tables for each tenant. Thanks
-
0
Hi,
You can use the "New seed code sample:" in this comment <a class="postlink" href="https://github.com/aspnetzero/aspnet-zero/issues/207#issuecomment-219463858">https://github.com/aspnetzero/aspnet-ze ... -219463858</a>. Place your tenant seed code in this if block
else if(SeedMode == SeedMode.Tenant) { //You can add seed for tenant databases... }