我正在使用代码首次迁移并尝试合并数据库(默认和FlavorPingRebuild),并且ApplicationUser表未添加到合并的数据库中。我不确定为什么没有添加表格。
namespace FlavorPingRebuild.Models
{
public class FlavorPingRebuildContext : IdentityDbContext
{
public FlavorPingRebuildContext() : base("name=FlavorPingRebuildContext")
{
}
public System.Data.Entity.DbSet<FlavorPingRebuild.Models.Merchant> Merchants { get; set; }
public System.Data.Entity.DbSet<FlavorPingRebuild.Models.MenuItem> MenuItems { get; set; }
public DbSet<IdentityUserLogin> UserLogins { get; set; }
public DbSet<IdentityUserClaim> UserClaims { get; set; }
public DbSet<IdentityUserRole> UserRoles { get; set; }
public DbSet<ApplicationUser> ApplicationUsers { get; set; }
protected override void OnModelCreating(DbModelBuilder builder)
{
//removes plural naming in DB tables
builder.Conventions.Remove<PluralizingTableNameConvention>();
//Removes cascade deletes.
builder.Conventions.Remove<OneToManyCascadeDeleteConvention>();
//When DB is created need to set up foreign key relationships.
builder.Entity<IdentityUserLogin>().HasKey<string>(l => l.UserId);
builder.Entity<IdentityRole>().HasKey<string>(r => r.Id);
builder.Entity<IdentityUserRole>().HasKey(r => new { r.RoleId, r.UserId });
}
}
}