【发布时间】:2019-07-02 13:07:32
【问题描述】:
如何为Openiddict-core 表设置默认方案?
不幸的是,EF Core 没有(我不知道)只接受方案的方法,并且 (EntityTypeBuilder.ToTable) 除了方案之外还需要表名。
【问题讨论】:
标签: openiddict
如何为Openiddict-core 表设置默认方案?
不幸的是,EF Core 没有(我不知道)只接受方案的方法,并且 (EntityTypeBuilder.ToTable) 除了方案之外还需要表名。
【问题讨论】:
标签: openiddict
没有什么特定于 OpenIddict 的来处理这个问题,但是使用常规的 EF 挂钩很容易实现。这是一个例子:
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public ApplicationDbContext(DbContextOptions options)
: base(options) { }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
// Customize the ASP.NET Identity model and override the defaults if needed.
// For example, you can rename the ASP.NET Identity table names and more.
// Add your customizations after calling base.OnModelCreating(builder);
foreach (var entity in builder.Model.GetEntityTypes())
{
for (var type = entity; type != null; type = type.BaseType)
{
if (type.ClrType.Assembly == typeof(OpenIddictApplication).Assembly)
{
entity.SqlServer().Schema = "security";
break;
}
}
}
}
}
【讨论】: