我使用的是.NET4.0、MVC3和EF5,代码优先.
我的解决方案分为三个项目,其依赖性如下所示:
Project.Web -> Project.BLL -> Project.DAL
这个项目.DAL层包含我的实体框架数据上下文类和所有实体,但我的启动项目是project.网络,所以它包含了我的网络.配置、连接字符串和实际的SQL compact数据库.
我正在try 启用迁移,以便在不删除现有数据的情况下向EF模型添加新表.然而,当我运行"启用迁移"时,我得到
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.)
有人知道为什么会出现这个错误,或者我能做些什么来修复它吗?