Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

Database.CompatibleWithModel Method (Boolean)

 

Checks whether or not the database is compatible with the the current Code First model.

Namespace:   System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

public bool CompatibleWithModel(
	bool throwIfNoMetadata
)

Parameters

throwIfNoMetadata
Type: System.Boolean

If set to true then an exception will be thrown if no model metadata is found in the database. If set to false then this method will return true if metadata is not found.

Return Value

Type: System.Boolean

True if the model hash in the context and the database match; false otherwise.

Model compatibility currently uses the following rules. If the context was created using either the Model First or Database First approach then the model is assumed to be compatible with the database and this method returns true. For Code First the model is considered compatible if the model is stored in the database in the Migrations history table and that model has no differences from the current model as determined by Migrations model differ. If the model is not stored in the database but an EF 4.1/4.2 model hash is found instead, then this is used to check for compatibility.

Return to top
Show:
© 2015 Microsoft