【发布时间】:2017-04-03 19:29:25
【问题描述】:
我正在尝试使用 aspnetcore 身份进行多租户,但是我在尝试修改“UserNameIndex”唯一索引以包含租户 ID 时遇到了麻烦。
我可以看到我要修改的索引如下(这是来自Microsoft.AspNetCore.Identity.EntityFrameworkCore/IdentityDbContext.cs)
b.HasIndex(u => u.NormalizedUserName).HasName("UserNameIndex").IsUnique();
这是我的 dbcontext 的摘录
public class MyContext : IdentityDbContext<Customer, CustomerRole, int>
{
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<Customer>().HasIndex(i => new { i.NormalizedUserName, i.TenantId }).HasName("UserNameIndex").IsUnique();
}
}
当我添加迁移时,这绝对没有影响 - 但是,如果我重命名索引,它会创建迁移!!不能覆盖索引吗?
【问题讨论】:
标签: asp.net-identity entity-framework-core entity-framework-migrations