Removing EdmMetadata table in EF Code First

 EF Code First Framework is using a table named EdmMetadata on the database to check the current model is compatible with the database. When your model is changing, you need to drop the database and create a new database. In that scenario, you can add a initialization strategy using DropCreateDatabaseIfModelChanges<TContext>. You can avoid the EdmMetadata table from your database so it won't check the schema of database with model. When you are using Code First Migrations or updating your database schema is manually, you don't need to EdmMetadata on the database. The following code in the DbContext class will not create EdmMetadata on the database.


  1. protected override void OnModelCreating(DbModelBuilder modelBuilder)
  2.         {
  3.             modelBuilder.Conventions.Remove<IncludeMetadataConvention>();
  4.         }


No Comments