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.
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:
See http://blogs.msdn.com/b/adonet/archive/2012/02/09/ef-4-3-released.aspx
The link for migrate.exe info is out-dated. Since this post helped me here is the latest for other folks who stumble upon this:
http://msdn.microsoft.com/en-us/data/jj618307.aspx
Summary: The article gives you instructions on getting migrate.exe installed and using the command line arguments to perform your migration scenario with it. In addition, common issues are identified. Bottom line install EF with nuget and browse to the package's tools folder to find the exe.
Here's a PowerShell function which does the equivalent of
update-database
in the Package Manager console, from a normal PowerShell window, using EF x.x.x.I'm using it from the command line as part of a 'full build' process on my dev machine;
The parameters are;
$solutionDir
-- the directory where your solution lives; the parent of thepackages
folder.$projectBinDir
-- the<something>\bin\debug
directory containing the assembly with yourDbContext
.$assemblyName
-- the name of the assembly file, likeMyEfProject.dll
appConfigFile
-- the name of theapp.config
orweb.config
file which contains connection strings etc. Equivalent to using-StartupProjectName
in the Package Manager console.If you have a look at the Nuget Faq it states the following:
But for using the code first migrations outside visual studio the release notes say the following:
As of today, you can use the
dotnet ef
command to use all code first command migrationExample :
Update-Database
-->
dotnet ef database update
Add-Migration AddProductReviews
-->
dotnet ef migrations add AddProductReviews
Remove-Migration
-->
dotnet ef migrations remove
Official document can be found here