当我运行我的代码时
using (foodEntities db_Linq = new foodEntities())
{
return db_Linq.Database.Exists();
//return db_Linq.Foods.Any();
}
我一直在 output
窗口中收到此错误。
A first chance exception of type 'System.InvalidOperationException' occurred in EntityFramework.dll
可能是什么问题? web.config 中的数据库凭据?
其他信息:
我的解决方案中实际上有 2 个项目。一个是类库,另一个是 MVC 4 web 项目。
类库使用 Entity Framework 连接。 Web 项目使用 ADO 连接字符串。
web项目调用类库时出现上述问题。
上面给出的代码来自类库。
最佳答案
您使用的是什么版本的 EF?在我看来,您使用的是 EF6,但命名空间有问题。
请检查Updating Applications to use EF6关联。您的主要部分是“更新正在使用的任何核心 EF 类型的命名空间”
关于c# - Entity Framework 设置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16686933/