解決Entity Framework Code First 的問題——Model compatibility cannot be checked because the database does not contain model metadata


這兩天在虛擬機里重新學習了一下ASP.NET MVC,然后就在Codeplex網站里面找到MVCMusicStore的代碼進行研究,跟着它的代碼一步一步學習下去。結果在使用EF的時候映射數據的時候,出現了下面的問題。如圖:

錯誤的提示為:Model compatibility cannot be checked because the database does not contain model metadata.Model compatibility can only be checked for databases created using Code First or Code First Migrations.

解決方法:

USE [master]
GO

/****** Object: Database [DBname] ******/
 ALTER DATABASE [DBname] SET SINGLE_USER WITH ROLLBACK IMMEDIATE
 ALTER DATABASE [DBname] SET SINGLE_USER WITH NO_WAIT
 DROP DATABASE [DBname]
 GO

DBname 即為你的數據庫名稱,執行完上面的這段Sql語句,上面出現的問題就解決了。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM