Model compatibility cannot be checked because the database does not contain model metadata

使用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语句,上面出现的问题就解决了。

posted @ 2014-02-14 10:08  风中娉婷  阅读(938)  评论(0编辑  收藏  举报