Entity framework error: Model compatibility cannot be checked because


Model compatibility cannot be checked because the database does not contain model metadata. Model compatibility can only be checked for databases created using Code First or Code First Migrations

Khắc phục

<add name=”AdventureWorksEntities”connectionString=”metadata=res://*/Models.AdventureWorks.csdl|res://*/Models.AdventureWorks.ssdl|res://*/Models.AdventureWorks.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=[YOUR DATA SOURCE];initial catalog=AdventureWorks;integrated security=True;multipleactiveresultsets=True;App=EntityFramework&quot;” providerName=”System.Data.EntityClient” />

Trong trường hợp không chỉ ra metadata thì dùng trong 

public ATMDBContext()
: base(“name=DefaultConnection”)
//Database.SetInitializer<ATMDBContext>(new DropCreateDatabaseAlways<ATMDBContext>());



Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s