0
leonkosak created
CreateOrMigrateForTenant(AbpTenantBase tenant, Action<TDbContext> seedAction);
in migrator executer: _migrator.CreateOrMigrateForTenant(tenant, SeedHelperTenantCustom.SeedTenantDb);
public class SeedHelperTenantCustom
{
public static void SeedTenantDb(IIocResolver iocResolver)
{
WithDbContext<ThynkrDemoDbContext>(iocResolver, SeedTenantDb);
}
public static void SeedTenantDb(ThynkrDemoDbContext context)
{
new InitialTenantDbBuilderCustom(context).Create();
}
private static void WithDbContext<TDbContext>(IIocResolver iocResolver, Action<TDbContext> contextAction)
where TDbContext : DbContext
{
using (var uowManager = iocResolver.ResolveAsDisposable<IUnitOfWorkManager>())
{
using (var uow = uowManager.Object.Begin(TransactionScopeOption.Suppress))
{
var context = uowManager.Object.Current.GetDbContext<TDbContext>(MultiTenancySides.Tenant);
contextAction(context);
uow.Complete();
}
}
}
}
How can I obtain tenantId for current tenant context in SeedTenantDb method (action)? Thank you.
3 Answer(s)
-
0
Hi Leon,
Could you try this https://github.com/aspnetzero/aspnet-zero-core/issues/1628
-
0
My bad. :( I forgot that I did this once in the past.
-
0
Hi, same question as above..this link is already dead --> https://github.com/aspnetzero/aspnet-zero-core/issues/1628 how can i achieve this?