简体   繁体   中英

Update the Package Manager console so Update-Database is available after Enable NuGet Package Restore

After I enabled Enable NuGet Package Restore on an Visual Studio ASP.Net MVC project, building in a clean git-clone works as NuGet downloads the necessary files, using packages.config . However, I then have to restart Visual Studio , for Update-Database to be available in the package manager console. I understand this probably has to do with the EntityFramework-package installing extensions for the Powershell Package Manager Console but how exactly does this work and isn't there a shortcut so I don't have to restart Visual Studio?

What exactly is the location of this Update-Database script? I cannot find it in ./packages/EntityFramework.5.0.0/ .

Also, I found it a bit unhandy that I also have to add ./.nuget/NuGet.exe to the git-repository. Is there a better way?

Having the PowerShell scripts available for Entity Framework after restoring the packages is unfortunately not currently supported without re-opening the solution or making sure the Package Manager Console is not open when the solution is first opened.

The Entity Framework NuGet package has a init.ps1 PowerShell script which sets up the various PowerShell commands in the Package Manager Console. The init.ps1 file is run when the solution/project is opened in Visual Studio, or after the Package Manager Console is opened for the first time with a solution already opened. Restoring the NuGet packages will restore the init.ps1 after the solution is open so this file will not be run. This is why the commands are not available in the console after a restore.

Instead of restarting Visual Studio you should be able to close and re-open the solution.

The Update-Database command, along with the other commands, are in one of the assemblies (EntityFramework.PowerShell.dll) that is included in the Entity Framework NuGet package.

For NuGet package restore you do not have to include .nuget/NuGet.exe file in your source control system if you do not want to. With recent versions of NuGet the package restore will be done automatically by Visual Studio just before the project is built. You can also restore the packages by running NuGet.exe restore YourSolution.sln from command line.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM