Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

EF Data Migrations does not work after close project

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

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?

EDIT : it works fine on another pc by the way...

like image 682
Eray Aydogdu Avatar asked Dec 17 '22 05:12

Eray Aydogdu


1 Answers

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.

You have to open VS in the following order:

  1. With VS open, close the package manager console
  2. Close VS
  3. Open VS
  4. Open your project
  5. Open the package manager console

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.


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.

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

like image 83
Matthew Avatar answered Mar 15 '23 22:03

Matthew