IncludeMetadataConvention Deprecated in EF 4.3

Tags: EF

In an earlier blog post I showed how to remove the IncludeMetadataConvention convention from your DbContext configuration. This is necessary up through EF 4.2 to prevent model metadata changes from being written to the database, something you don't want for legacy systems. Beginning with EF 4.3 this pluggable convention has been deprecated. As posted on the ADO.NET team blog:

In CTP5 we have removed the need to perform additional configuration when mapping to an existing database. If Code First detects that it is pointing to an existing database schema that it did not create then it will 'trust you' and attempt to use code first with the schema.

Super cool. I like it when the tool trusts me. If I get a schema error then let me handle it in my fluent API mapping. Don't try to create tables or columns for me. So with the obsolesence of IncludeMetadataConvention the MyContext class is much simpler:

public class MyContext : DbContext
{
    public DbSet<Foo> Foos { get; set; }
    public DbSet<Bar> Bars { get; set; }
}
Add a Comment