Search code examples
entity-frameworkasp.net-identity

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


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.


Solution

  • 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.