I need to use an ‘DropCreateDatabaseIfModelChanges’ – Initializer class, because I want to create one special entity (table), if it doesn’t exist. My problem is, that I’ve also got another entity in my DbContext, which shouldn’t be part of the model compatibility check.
I’m getting the following error message:
Model compatibility cannot be checked because the EdmMetadata type was not inclu
ded in the model. Ensure that IncludeMetadataConvention has been added to the Db
ModelBuilder conventions.
Is there any possibility to exclude a special entity from this check?
EDIT:
I’ve done what Devart has suggested. The problem seems to be different, than I first tought. It all works fine, if I let EF create a new database with my CheckedContext. But I’m getting the error message above, when I’ll try to use my NonCheckedContext wich should use an existing table …
EDIT2:
This is a working solution. Everything works fine, when the database doesn’t exist before. But it’s no option for me, to Drop/Create the database.
A possible solution: create a context class inherited from DbContext, and then create two separate subcontexts inherited from the base one – CheckedContext and NonCheckedContext, and set the Database Initialization Strategy accordingly.
Please note that you should access the CheckedContext first so that it fires all its checks.