0
我试图使用aspnetcore标识来做多租户,但是我遇到了麻烦,试图修改“UserNameIndex”唯一索引以包含tenantid。EF7 IdentityDbContext迁移修改索引
我可以看到我想要修改的指数是以下(这是从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();
}
}
当我添加一个迁移,这绝对没有影响 - 但是,如果我重命名索引它创建迁移!是否可以重写索引?