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;
function Update-Database($solutionDir, $projectBinDir, $assemblyName, $appConfigFile)
{
$efMigrateExe = "$solutionDir\packages\EntityFramework.*\tools\migrate.exe"
Write-Host "Updating Entity Framework Database"
Write-Host " Migrate.exe at $efMigrateExe"
Write-Host " EF project binary at $projectBinDir"
Write-Host " EF config at $appConfigFile"
. "$efMigrateExe" "$assemblyName" /startupConfigurationFile="$appConfigFile" /startupDirectory="$projectBinDir"
}
The parameters are;
$solutionDir
-- the directory where your solution lives; the parent of the packages
folder.
$projectBinDir
-- the <something>\bin\debug
directory containing the assembly with your DbContext
.
$assemblyName
-- the name of the assembly file, like MyEfProject.dll
appConfigFile
-- the name of the app.config
or web.config
file which contains connection strings etc. Equivalent to using -StartupProjectName
in the Package Manager console.