天天看點

解決MVC EF Code First錯誤:Model compatibility cannot be checked because the EdmMetadata type was not included in the model.

Model compatibility cannot be checked because the EdmMetadata type was not included in the model. Ensure that IncludeMetadataConvention has been added to the DbModelBuilder conventions.      

分析:

碰到此錯誤是由于使用了EF Code First來生成資料庫,生成資料庫之後又修改了模型。 

兩種解決方式:

1.在Global.asax.cs的Application_Start()方法中将Database.SetInitializer<xxxDbContext>(new DatabaseInitializer());改為Database.SetInitializer<xxxDbContext>(null)(如果有初始化資料庫的資料方法的前提下)

2.删除資料庫(治标不治本)。

解決MVC EF Code First錯誤:Model compatibility cannot be checked because the EdmMetadata type was not included in the model.
解決MVC EF Code First錯誤:Model compatibility cannot be checked because the EdmMetadata type was not included in the model.
USE MASTER
GO
DROP DATABASE [DBNAME]      

View Code

作者:楓上善若水

出處:http://www.cnblogs.com/xilipu31/

本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連結。

正在看本人部落格的這位童鞋,我看你氣度不凡,談吐間隐隐有王者之氣,日後必有一番作為!旁邊有“推薦”二字,你就順手把它點了吧,相得準,我分文不收;相不準,你也好回來找我!

繼續閱讀