从ssms中删除迁移文件夹和数据库后,我在运行add migration命令时遇到了这个错误。
这是我的ApplicationDatabaseContext:
public class ApplicationDatabaseContext : IdentityDbContext
{
public ApplicationDatabaseContext(DbContextOptions<ApplicationDatabaseContext> options) : base(options)
{
}
public DbSet<CommentGroup> CommentGroup { get; set; }
public DbSet<Review> Reviews { get; set; }
public DbSet<Comment> Comments { get; set; }
public DbSet<Websites> Websites { get; set; }
protected override void OnModelCreating(ModelBuilder builder)
{
base.OnModelCreating(builder);
builder.Entity<IdentityUser>(entity =>
{
entity.ToTable(name: "User");
});
builder.Entity<IdentityRole>(entity =>
{
entity.ToTable(name: "Role");
});
builder.Entity<IdentityUserRole<string>>(entity =>
{
entity.ToTable("UserRoles");
});
builder.Entity<IdentityUserClaim<string>>(entity =>
{
entity.ToTable("UserClaims");
});
builder.Entity<IdentityUserLogin<string>>(entity =>
{
entity.ToTable("UserLogins");
});
builder.Entity<IdentityRoleClaim<string>>(entity =>
{
entity.ToTable("RoleClaims");
});
builder.Entity<IdentityUserToken<string>>(entity =>
{
entity.ToTable("UserTokens");
});
}
}
我刚刚从ssms中删除了迁移文件夹和数据库,并运行了add migration命令。
通过在AplicationDatabaseContext.cs.中添加一个空构造函数解决的问题