Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using NuGet Package Manager console outside Visual Studio to run Entity Framework Migrations

Tags:

Is there anyway to open NuGet Package Manager console outside Visual Studio ?

My objective is to run some migrations, which I created using EntityFramework.Migrations

Basically I want to run Update-Database –Verbose command in an environment which does not have visual studio, but does have PowerShell 2.0 and NuGet command line tool.

like image 260
Zasz Avatar asked Oct 26 '11 13:10

Zasz


People also ask

How do I run migration in Package Manager console?

Open the Package Manager Console from Tools → Library Package Manager → Package Manager Console and then run the enable-migrations command (make sure that the default project is the project where your context class is).

What happens when an add migration command is executed in the NuGet Package Manager console?

Add-Migration Adds a new migration. Remove-Migration Removes the last migration. Scaffold-DbContext Scaffolds a DbContext and entity type classes for a specified database. Script-Migration Generates a SQL script from migrations.


1 Answers

The original posted answer was right at the time, but now (as of 4.3) there is a migrate.exe so you don't need nuget or powershell:

packages\EntityFramework.4.3.1\tools\migrate.exe 

See http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx

like image 106
Scott Stafford Avatar answered Sep 23 '22 20:09

Scott Stafford