我正在使用.NET 4.0、MVC3和EF5与代码优先的方式。
我的解决方案分为三个项目,其依赖关系如下:
Project.Web -> Project.BLL -> Project.DAL
Project.DAL层包含我的Entity Framework数据上下文类和所有实体,但我的启动项目是Project.Web,因此它包含了我的Web.config、连接字符串和实际的SQL Compact数据库。
我尝试启用迁移,以便在不清除现有数据的情况下向我的EF模型添加新表。但是,当我运行“Enable-Migrations”时,我得到以下内容:
No context type was found in the assembly 'Project.Web'.
如果我将启动项目设置为Project.DAL,则错误会更改为
Could not load assembly 'Project.Web'. (If you are using Code First Migrations inside Visual Studio this can happen if the startUp project for your solution does not reference the project that contains your migrations. You can either change the startUp project for your solution or use the -StartUpProjectName parameter.)
有没有人知道这个错误是什么原因引起的或者我可以做些什么来修复它?