Problem “Could not load file or assembly ’<assembly>’ or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)" when using Entity Framework’s migrate.exe
When you use migrate.exe
from Entity Framework’s Migrations (in time of writing 4.3.1) you might get the error saying:
Could not load file or assembly ’
’ or one of its dependencies. The given assembly name or codebase was invalid. (Exception from HRESULT: 0x80131047)
That’s nice, but nothing special, right? The reason is simple and as lot of magic execution errors it is current/working directory related. To fix it, simply explicitly specify path (relative works) to your assembly using StartUpDirectory
parameter. And there’s another one gotcha. This parameter works only with :
. Let me explain.
migrate.exe /StartUpDirectory C:\Foo\Bar\Baz
Doesn’t work (and no error). But this one.
migrate.exe /StartUpDirectory:C:\Foo\Bar\Baz
Does.
Hope it saves you some time hunting what’s wrong.