EF Code Frirst: Before you update your database using Code First Migrations,

asp.net-identity entity-framework

Question

I just updated EntityFramework from V6.0.2 to V6.1 and also to the latest ASP.NET Identity. After that I tried to create a migration file for limiting the length of the username which is now possible with the new version of ASP.NET Identity Framework released today.

This is the error message I got:

The model backing the 'ApplicationDbContext' context has changed since the database was created. This could have happened because the model used by ASP.NET Identity Framework has changed or the model being used in your application has changed. To resolve this issue, you need to update your database. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=301867). Before you update your database using Code First Migrations, please disable the schema consistency check for ASP.NET Identity by setting throwIfV1Schema = false in the constructor of your ApplicationDbContext in your application. public ApplicationDbContext() : base("ApplicationServices", throwIfV1Schema:false)

I'm especially interested in this line:

Before you update your database using Code First Migrations, please disable the schema consistency check for ASP.NET Identity by setting throwIfV1Schema = false in the constructor of your ApplicationDbContext in your application.

Why would I want to do that? And for how 'long'?

Also, I haven't changed anything in the model since before and after the update.

1
9
3/20/2014 11:30:29 PM

Accepted Answer

I believe it's a one time occurrence while you upgrade your database.

You can read more at the .NET Web Development and Tools Blog. And also see Updating ASP.NET applications from ASP.NET Identity 1.0 to 2.0.0-alpha1 linked from that blog post.

9
3/21/2014 10:50:31 AM

Popular Answer

Bool param throwIfV1Schema throws exception that asp.net Identity model has been changed (updated to new version 2).

Change your IdentityDbContext constructor for one time migration:

public YourDbContext() : base("YourConnectionString", throwIfV1Schema:false){}


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow