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