I have been struggling on executing EF Migrate.exe to work.
My Solution has couple of projects. The migrations and the entities live in the project Data. The controllers and views live in Web.
I tried using the migrate.exe - however I am struggling getting the first argument (assembly) to be accepted. Documentations says:
Assembly: Specifies the name of the assembly that contains the migrations configuration type.
I have tried:
migrate.exe "MySolution\DataProject\bin\Debug\Data.dll"
ERROR: Could not load file or assembly 'D:\\MySolution\\Data\\bin\\Debug\\Data' or one of its dep
endencies. The given assembly name or codebase was invalid. (Exception from HRES
ULT: 0x80131047)
Any idea what is going wrong?
Migrate.exe (FluentMigrator. This is a console tool that works also with the . NET Framework outside of the . NET Core ecosystem.
The ef6.exe command line tool is found in the tools/ subfolder of the EntityFramework NuGet package.
After reading this, this, and this
I have (I think) what you need :
C:\Tools\migrate.exe some.dll /StartUpDirectory=C:\Project\bin\
. C:\Tools\migrate.exe C:\Project\bin\some.dll
- In this scenario migrate.exe will not be able to load the some.dll's dependencies, unless you put all some.dll's dependencies and put it in the SAME directory as migrate.exe.C:\Tools\migrate.exe some.dll
/StartUpDirectory=<the path where you target dll is present>
clause, and you should specify the name of the assembly without the path like : C:\Tools\migrate.exe some.dll /StartUpDirectory=C:\Project\bin\
$SolutionPath = (Resolve-Path '..').Path
$ToolsPath = "$SolutionPath\Build\Lib\"
task db {
$migrator = $ToolsPath + 'Migrations\migrate.exe'
$migrateCommand = "$migrator zasz_me.dll /StartUpDirectory=$SolutionPath\zasz.me\bin\ /connectionStringName:FullContext /startUpConfigurationFile:$SolutionPath\zasz.me\Web.config /verbose"
Write-Host $migrateCommand
Invoke-Expression $migrateCommand
}
I answered a similar question here on how to override connectionstring through parameters to migrate.exe. I have yet to get it working without specifying a web/app.config file.
https://stackoverflow.com/a/14138797/134761
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With