Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Where is modelBuilder.IncludeMetadataInDatabase in EF CTP5?

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.

like image 416
Daniel Liuzzi Avatar asked Dec 19 '10 19:12

Daniel Liuzzi


2 Answers

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:

modelBuilder.Conventions
            .Remove<System.Data.Entity.Database.IncludeMetadataConvention>();
like image 197
Morteza Manavi Avatar answered Nov 06 '22 16:11

Morteza Manavi


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

System.Data.Entity.Database.DbDatabase.SetInitializer<MyDBContext>(null);
like image 3
LordHits Avatar answered Nov 06 '22 16:11

LordHits