Context Has Changed Since the Database Was Created

This article describes and provides the solutions of a common error in Entity Framework: 
"Context has changed since the database was created, Model backing a DB Context has changed, Model backing the context has changed since the database was created."

This is the most frequent error in Entity Framework. This type of error occurred when the model and the database cannot be mapped correctly. That means there is a modification or changed in the database. We made any type of schema change on the table or database after including Entity Data Model in the project or solutions.

To solve this error write the following code in Application_Start() Method in Global.asax.cs file.
Database.SetInitializer<CustomerDBContext>(null);

That means we need to bind our DB context class with a null value. If the database schema is changed, it is mandatory to updates the .edmx file.

Comments