就我而言,我遇到了类似的问题,出现以下错误:
Error 1 The type 'System.Data.Entity.DbContext' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. C:\Projects\MyProject\MyProject.Model.Net\ProductManager.cs 16 17 MyProject.Model.Net
Error 2 The type 'System.Data.Entity.DbSet`1<T0>' is defined in an assembly that is not referenced. You must add a reference to assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. C:\Projects\MyProject\MyProject.Model.Net\ProductManager.cs 17 17 MyProject.Model.Net
Error 3 'System.Data.Entity.DbSet`1<MyProject.Data.ProductInventoryView>' does not contain a definition for 'Where' and no extension method 'Where' accepting a first argument of type 'System.Data.Entity.DbSet`1<MyProject.Data.ProductInventoryView>' could be found (are you missing a using directive or an assembly reference?) C:\Projects\MyProject\MyProject.Model.Net\ProductManager.cs 18 21 MyProject.Model.Net
Error 4 Metadata file 'C:\Projects\MyProject\MyProject.Model.Net\bin\Debug\MyProject.Model.Net.dll' could not be found C:\Projects\MyProject\MyProject.Web\CSC MyProject.Web
为了解决这个问题,我需要添加 EntityFramework.dll 引用 MyProject.Data 项目,方法是浏览到此目录以选择文件:~\MyProject\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll