关闭项目后,EF数据迁移不起作用 [英] EF Data Migrations does not work after close project

查看:149
本文介绍了关闭项目后,EF数据迁移不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用实体框架数据迁移.如果我更改了有关实体的内容或其他内容,则尝试在Package Manager控制台上使用" add-migration MyFirstMigration ".但是它返回一个异常:

i'm using entity framework data migrations. if i change something about entites or something else, i try to use "add-migration MyFirstMigration" on Package Manager Console. But it returns an exception :

The term 'add-migration' is not recognized as the name of a cmdlet, function, script  file, or operable program. Check the spelling of the name, or if a path was inclu
ded, verify that the path is correct and try again.
At line:1 char:14
+ add-migration <<<< 
+ CategoryInfo          : ObjectNotFound: (add-migration:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

如果我从Nuget卸载EntityFramework.Migrations并重新安装,则使用相同的代码(" add-migration MyFirstMigration "," update-database ")直到关闭项目.

if i uninstall EntityFramework.Migrations from Nuget and re-install it's working with same code ("add-migration MyFirstMigration","update-database") till close project.

我该如何解决?有人遇到这个吗?

how can i fix it ? anyone else experiencing this?

顺便说一下,它可以在另一台PC上正常工作...

推荐答案

尽管我正在测试VS 11和EF5,但我也遇到了这个问题,因此这可能不适用于您.可能有两件事.

I ran into this also, although I am testing VS 11 and EF5, so this may not apply to you. It could be a couple of things.

您必须按以下顺序打开VS:

You have to open VS in the following order:

  1. 打开VS,关闭包管理器控制台
  2. 关闭VS
  3. 打开VS
  4. 打开您的项目
  5. 打开程序包管理器控制台

如果关闭VS,则在打开包管理器控制台时,它会记住这一点.然后,当您重新打开VS时,在打开项目之前,程序包管理器控制台已经打开,并且感到困惑.

If you close VS, when the package manager console is open, it remembers that. Then, when you reopen VS, the package manager console is already open before you open your project and it gets confused.

另一种可能性是您安装了其他不了解"add-migration"的EF软件包,并且它们正在妨碍您的使用.

The other possibility is that you have other EF packages installed that don't know about "add-migration" and they are geting in the way.

在程序包管理器控制台中运行"get-package",以查看安装了什么.删除不必要的/旧的东西.

Run "get-package" in the package manager console, to see what is installed. Remove the unnecessary/old stuff.

这篇关于关闭项目后,EF数据迁移不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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