EF 4 Code First: Model compatibility cannot be checked because the EdmMetadata type was not included in the model

Well it feels somewhat silly but the real culprit was following statement:

Database.SetInitializer(new DropCreateDatabaseIfModelChanges<MyContext>());

It seems that DropCreateDatabaseIfModelChanges is not compatible with Code First approach or it is some other mystery that I don't understand (yet).


Removing IncludeMetadataConvention means the initializer cannot tell when the model changes. Adding it back in won't help either because it only creates the meta data table on db creation, which obviously won't exist for preexisting databases or databases that were created with the convention disabled.

Solution is dropping the database and enabling the convention, or disabling the initializer and updating the database another way (manual or ef migrations)