无法启用类库中的实体框架迁移
-
15-11-2019 - |
题
我刚刚使用ef 5和我使用他们的代码第一迁移工具,但是当我尝试启用迁移时,我似乎收到错误。
i键入Enable-Migrations
到包管理器控制台中,然后它说
没有从当前项目中找到的dbcontext派生的课程。
编辑生成的配置类以指定要启用迁移的上下文。
代码为Project MyApp.MVCUI启用了第一个迁移。然后它在my mvcui项目中创建迁移文件夹和配置类。事情是,我的dbcontext生活在一个名为myapp.domain的库图书馆项目中。它应该在这个项目中做到这一切,并且应该没有问题找到我的dbcontext。
解决方案
Oh wow, nevermind. I'm dumb.
In the Nuget package manager console there is a dropdown menu at the top labeled "Default Project:". Make sure you set that to the project you want to run the command against.
Hopefully this helps someone else avoid my embarrassing mistake.
其他提示
There are actually 3 ways to make Nuget commands run in a specific project:
- [Package Manager Console] Set the active project in the dropdown at the top of the console toolwindow
- [Package Manager Console] Look for a parameter to specify the project. For some cmdlets I've seen -ProjectName and some use -Project
- [Solution Explorer] Right-click the project you want, and use the graphical package manager window (Manage NuGet Packages...).
不隶属于 StackOverflow