不能启用类库实体框架迁移 [英] Cannot enable migrations for Entity Framework in class library

查看:123
本文介绍了不能启用类库实体框架迁移的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚上船的时候就与EF 5和正在使用他们的代码,第一个迁移工具,但我似乎得到一个错误,当我尝试启用迁移。

I just got on board with EF 5 and am using their code-first migrations tool but I seem to get an error when I try to enable migrations.

我键入启用的迁移进入包管理器控制台,然后它说

I type Enable-Migrations into the package manager console and then it says

没有班从派生的DbContext在当前项目中找到。结果
编辑生成的配置类指定上下文,使迁移的。结果
码首先迁移项目MyApp.MvcUI启用。

No classes deriving from DbContext found in the current project.
Edit the generated Configuration class to specify the context to enable migrations for.
Code First Migrations enabled for project MyApp.MvcUI.

然后,它创建了一个迁移文件夹和我MvcUI项目中配置类。事情是,我的DbContext住在被称为MyApp.Domain一个类库项目。应该尽一切在该项目中,应该没有问题,找到我的DbContext。

It then creates a Migrations folder and a Configuration class in my MvcUI project. Thing is, my DbContext lives in a class library project called MyApp.Domain. It should be doing all that in that project and should have no problem finding my DbContext.

推荐答案

哇哦,请不要介意。我是哑巴

Oh wow, nevermind. I'm dumb.

在的NuGet包管理器控制台有标记在顶部的下拉菜单默认项目。请确保您设置的项目要运行对命令。

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.

这篇关于不能启用类库实体框架迁移的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆