Take the 2-minute tour ×

With CTP4, I used to be able to do the following (as suggested by ptrandem):

modelBuilder.IncludeMetadataInDatabase = false

With this line of code, EF doesn't create the EdmMetadata table in my database, and doesn't track model changes.

I was unable to find a way to accomplish this in the new CTP5, so now every time I change my model, I get this:

The model backing the 'MyContext' context has changed since the database was created. Either manually delete/update the database, or call Database.SetInitializer with an IDatabaseInitializer instance. For example, the DropCreateDatabaseIfModelChanges strategy will automatically delete and recreate the database, and optionally seed it with new data.

So, does everybody know where is the IncludeMetadataInDatabase property in CTP5? Thanks.

share|improve this question

4 Answers 4

up vote 11 down vote accepted

CTP5 includes a very cool feature called Pluggable Conventions that can be used to Add/Remove conventions. IncludeMetadataInDatabase has been removed and being replaced with a
pluggable convention that does the same thing for you:

share|improve this answer
Thanks, Morteza. Do you know if there are any other differences between doing this, and just dropping the EdmMetadata table as the ADO.NET team blog states? What is preferable? –  Daniel Liuzzi Dec 19 '10 at 23:40
No problem. I think the one you found on team's blog is talking about existing databases and the one I suggested is for when you are generating a DB from your object model. At the end of the day they both have a same result: you have a POCO object model that works with a database without a Metadata table so I think it depends on your scenario (a brand new database or an existing one). –  Morteza Manavi Dec 19 '10 at 23:53
Excellent. Thanks a lot! –  Daniel Liuzzi Dec 20 '10 at 0:01
You are very welcome, glad it helped :) –  Morteza Manavi Dec 20 '10 at 0:23
In latest release, this got moved to modelBuilder.Conventions.Remove<System.Data.Entity.Infrastructure.IncludeMetadat‌​aConvention>(); –  bkaid Apr 24 '11 at 6:35

The equivalent in CTP5 to switch off initializer logic: In your Application_Start in Global.asax, enter the following:

share|improve this answer

In EF 4.1

protected override void OnModelCreating(DbModelBuilder modelBuilder)
share|improve this answer

Have been looking for this all over, and I had to find the answer right after posting my question, DUH. Right from 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. The easiest way to point Code First to an existing database is to add a App/Web.config connection string with the same name as your derived DbContext (...)

share|improve this answer

Your Answer


