【发布时间】:2012-10-13 11:23:49
【问题描述】:
我首先使用带有代码的 .NET 4.0、MVC3 和 EF5。
我的解决方案分为三个项目,其依赖关系如下所示:
Project.Web -> Project.BLL -> Project.DAL
Project.DAL 层包含我的实体框架数据上下文类和我的所有实体,但我的启动项目是 Project.Web,因此它包含我的 Web.config、连接字符串和实际的 SQL 紧凑型数据库。
我正在尝试启用迁移,以便在不擦除现有数据的情况下将新表添加到我的 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.)
有谁知道为什么会出现这个错误或者我可以做些什么来修复它?
【问题讨论】:
标签: asp.net entity-framework connection-string data-access-layer entity-framework-5