EF Core - Running migrations without sources - Equivalent of EF6's migrate.exe
My team colleague found a way which allows you to run migrations on build artefacts without sources. Following command replace migrate.exe
for us:
dotnet exec
--runtimeconfig ./HOST.runtimeconfig.json
--depsfile ./HOST.deps.json Microsoft.EntityFrameworkCore.Design.dll
--assembly ./DB_CONTEXT_DLL.dll
--startup-assembly ./HOST.dll --data-dir ./
--root-namespace DB_CONTEXT_NAMESPACE
--verbose database update --context DB_CONTEXT_CLASS -e development
Update for 2.1.x version:
dotnet exec
--runtimeconfig ./HOST.runtimeconfig.json
--depsfile ./HOST.deps.json /PATH/TO/microsoft.entityframeworkcore.tools/.../ef.dll
--verbose database update --context DB_CONTEXT_CLASS
--assembly ./DB_CONTEXT_DLL.dll
--startup-assembly ./HOST.dll --data-dir ./
Seems not possible run dotnet ef database update
only with the DLL, and if you use the docker, the actual version of runtime microsoft/dotnet:1.1.0-preview1-runtime
do not have the sdk installed (with the dotnet ef database update
command).
One option to update database without use dotnet ef database update
is execute the command bellow in some default action or startup routine.
_dbContext.Database.Migrate();