Friday, 15 November 2013

The model backing the ‘contextname’ context has changed since the database was created..

The model backing the ‘contextname’ context has changed since the database was created. Consider using code First Migration to update the database (http://go.microsoft.com/fwlink/?LinkId=238269



Solution 1: Create a static function in the Context class
public static void InitializeDataContext()
        {
            Database.SetInitializer<YourContextClass>(null);
        }

Call InitializeDataContext() method from Application_Start() method of global.asax
protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RegisterGlobalFilters(GlobalFilters.Filters);
            RegisterRoutes(RouteTable.Routes);

            SmokeTest.InitializeDataContext();
        }

No comments:

Post a Comment