IdentityDbContext如何运行迁移 [英] IdentityDbContext how to run migrations

查看:182
本文介绍了IdentityDbContext如何运行迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Entity-Framework-5和IdentityDbContext的新手,我设法创建并创建了AspNet成员表,然后我更改了模型属性之一的类型,现在我的项目将无法运行,并且不会告诉我我需要运行迁移.我的问题是,如何在IdentityDbContext上运行迁移? 我找不到任何很好的指南.

I am new to Entity-Framework-5 and IdentityDbContext, I have managed to create my and create the AspNet membership tables,then i changed the type in one of the properties of the model, now my project wont run and its telling me that I need to run migrations. My question is, how to run migrations on the IdentityDbContext? I cant find any good guides on how to do it.

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时,我已经附加了错误.

public class ApplicationIdentityUserDbContext : IdentityDbContext<UserProfile> { public ApplicationIdentityUserDbContext() : base("DefaultConnection") { } } I have attached the error when I run enable-migrations.

推荐答案

您可以使用中的 enable-migrations add-migration 命令来执行此操作程序包管理器控制台 请参见代码优先迁移

You do it by using the enable-migrations and add-migration command in the Package Manager Console See Code First Migrations

这将生成迁移文件,您可以使用 update-database 命令将其应用于数据库(或根据设置自动运行).

This will generate migration files which you can apply to the database using the update-database command (or they run automatically depending on settings).

确保在 Package Manager控制台中选择正确的默认项目,它应该是包含您的上下文的项目.

Make sure to select the correct Default Project in the Package Manager Console, it should be the project containing your context.

这篇关于IdentityDbContext如何运行迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆