Entity Framework 6.1.1 disable model compatibility checking

c# console-application entity-framework

Question

I am running into the following error after updating EF to version 6.1.1:

An unhandled exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll

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

We could fix this in the past as described in this question: Where is modelBuilder.IncludeMetadataInDatabase in EF CTP5?

However, I can't seem to get rid of the error.

1
19
5/23/2017 12:18:11 PM

Accepted Answer

This should work, put it somewhere in the constructor of your derived DbContext:

Database.SetInitializer<MyContext>(null);
65
7/21/2014 9:49:01 AM

Popular Answer

You can also set it in Web.config file

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <appSettings>    
    <add key="DatabaseInitializerForType YourNamespace.YourDbContext, AssemblyName"
            value="Disabled" />
    </appSettings>
</configuration>

Decision from: http://www.entityframeworktutorial.net/code-first/turn-off-database-initialization-in-code-first.aspx



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