Home > Tips & Tricks > Model compatibility cannot be checked – Error

Model compatibility cannot be checked – Error

December 2nd, 2011 Leave a comment Go to comments

You usually encountered problem like:

ERROR: Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.NotSupportedException: Model compatibility cannot be checked because the database does not contain model metadata. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.

This exception can occur specially when you are using different SQL Server version. A quick solution to this problem i found is, if you are using EF do the following in your dbContext:

protected override void OnModelCreating(ModelBuilder modelBuilder)
{
modelBuilder.Conventions.Remove<IncludeMetadataConvention();
}


  1. No comments yet.
  1. No trackbacks yet.