解决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