IdentityDbContext how to run migrations

◇◆丶佛笑我妖孽 提交于 2019-12-13 05:24:00

问题


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") { } } I have attached the error when I run enable-migrations.


回答1:


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

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

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



来源:https://stackoverflow.com/questions/32776586/identitydbcontext-how-to-run-migrations

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!