The model backing the '' context has changed since the database was created. Consider using Code Fir

Posted by Sheonarayan under Error and Solution on 5/27/2014 | Points: 10 | Views : 4639 | Status : [Administrator] | Replies : 0

Problem

I was getting below error while working with ASP.NET MVC in 2013 IDE. It took me many hours to find out the real cause and fix the bug. There were several pointers on Stackoverflow or other website but all were creating more problem than solving the issue.

The model backing the '' context has changed since the database was created. Consider using Code First Migrations to update the database (http://go.microsoft.com/fwlink/?LinkId=238269).

Solution
Solution of this problem is to change the Application_Start() method of the Global.asax.cs page like below

  protected void Application_Start()
{
Database.SetInitializer<DatabaseInteractionLINQ.Models.DatabaseInteractionLINQContext>(null);

AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
}


Notice, this line of code Database.SetInitializer<DatabaseInteractionLINQ.Models.DatabaseInteractionLINQContext>(null);

Hope this will be helpful to someone looking for similar problem.

Regards,
Sheo Narayan
http://www.dotnetfunda.com



Responses

(No response found.)

Login to post response