【发布时间】:2015-09-25 07:03:44
【问题描述】:
我是 Entity-Framework-5 和 IdentityDbContext 的新手,我已经成功创建并创建了 AspNet 成员表,然后我更改了模型属性之一中的类型,现在我的项目无法运行并且它告诉我需要运行迁移。我的问题是,如何在 IdentityDbContext 上运行迁移? 我找不到任何关于如何做的好指南。
Additional information: The model backing the 'ApplicationIdentityUserDbContext' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).
public class ApplicationIdentityUserDbContext : IdentityDbContext<UserProfile>
{
public ApplicationIdentityUserDbContext()
: base("DefaultConnection")
{ }
}
我在运行 enable-migrations 时附加了错误。
【问题讨论】:
-
运行显示我拥有的 dbContext,当我尝试使用 configtypename 添加迁移时,我收到一条错误消息,告诉我无法在指定的 dbConext 上运行迁移
-
oes not inherit from 'System.Data.Entity.Migrations.DbMigrationsConfiguration'. Migrations configuration types must extend from 'System.Data.Entity.Migrations.DbMigrationsConfiguration'. -
您需要为 DBContext 而不是 IdentityContext 类添加迁移。试试这个
-
当我尝试这样做时,我收到一条错误消息,指出迁移已启用,并且没有尝试 -force 选项,因为我不确定它会对我的 aspnet 成员身份进行更改。跨度>
标签: c# asp.net asp.net-mvc asp.net-mvc-4 entity-framework-5