-
-
Notifications
You must be signed in to change notification settings - Fork 287
Closed
Description
Andrew,
I would like to configure the asp_net_roles table as not multitenant. I have used the IsNotMultitenant() method in my ApplicationRole configuration, but the table still gets created with the tenant_id column. The docs say all entities will be configured as multitenant by default. The asp_net_users table is created without the tenant_id, but the roles table is not. Is it possible to make the roles table not multitenant?
public sealed class ApplicationRoleConfiguration : IEntityTypeConfiguration<ApplicationRole>
{
public void Configure(EntityTypeBuilder<ApplicationRole> builder)
{
builder.IsNotMultiTenant();
}
}
public sealed class IdentityApiDbContext : MultiTenantIdentityDbContext<ApplicationUser, ApplicationRole, string>
{
public IdentityApiDbContext(IMultiTenantContextAccessor<AppTenantInfo> multiTenantContextAccessor,
DbContextOptions<IdentityApiDbContext> options): base(multiTenantContextAccessor, options)
{
}
public IdentityApiDbContext(IMultiTenantContextAccessor<AppTenantInfo> multiTenantContextAccessor) : base(multiTenantContextAccessor)
{
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.ApplyConfiguration(new ApplicationUserConfiguration());
modelBuilder.ApplyConfiguration(new ApplicationRoleConfiguration());
// Preserve snake case naming convention
foreach (var entityType in modelBuilder.Model.GetEntityTypes())
{
// Set the table name to be the same as the entity type name
entityType.SetTableName(entityType.GetTableName().ToSnakeCase());
foreach (var property in entityType.GetProperties())
{
property.SetColumnName(property.Name.ToSnakeCase());
}
}
}