问题
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