sfgroups
sfgroups

Reputation: 19099

Entity framework CTP5 Model compatibility cannot be checked because the database does not contain model metadata

I am trying to test the Entity Framework CTP 5 Code First with an existing table.

  1. I defined the model class and DbContext and ran the application. It created the database and table.
  2. I dropped EdmMetadata table from the database.
  3. Added Trusted_Connection=true;Persist Security Info=True in my connection string.
  4. When I run the application again, it gives me this error.

System.NotSupportedException was unhandled by user code
Message=Model compatibility cannot be checked because the database does not contain model metadata.
Source=EntityFramework

How can I make this application run without EdmMetadata table?

Upvotes: 3

Views: 8654

Answers (1)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364249

If you don't want to use EdmMetadata table try to add this into your DbContext derived class:

protected override void OnModelCreating(ModelBuilder modelBuilder) 
{
    modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
}

Upvotes: 6

Related Questions