-1
我创建了一个名为“SupportTicket”的模型,并尝试创建一个迁移到脚手架数据库,但迁移文件恢复为空白。我已启用迁移。添加迁移不将模型添加到迁移文件
的SupportTicket模型
public class SupportTicket
{
[Key]
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
}
的DAO文件:
public class ApplicationUser : IdentityUser
{
public async Task<ClaimsIdentity> GenerateUserIdentityAsync(UserManager<ApplicationUser> manager)
{
// Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
// Add custom user claims here
userIdentity.AddClaim(new Claim("FirstName", FirstName.ToString()));
userIdentity.AddClaim(new Claim("LastName", LastName.ToString()));
return userIdentity;
}
public string FirstName { get; set; }
public string LastName { get; set; }
}
public class ApplicationDbContext : IdentityDbContext<ApplicationUser>
{
public DbSet<SupportTicket> SupportTickets { get; set; }
public ApplicationDbContext()
: base("DefaultConnection")
{
}
public static ApplicationDbContext Create()
{
return new ApplicationDbContext();
}
}
输出迁移文件:
public partial class added_support_ticket : DbMigration
{
public override void Up()
{
}
public override void Down()
{
}
}
我在做什么黄?这是我第一次使用Migrations,而且我很少知道自己在做什么。
在此先感谢您的帮助。
尝试构建解决方案并删除旧的迁移并再次运行迁移。 – ISHIDA