EF Core - Starting migration without sources - Equivalent to EF6 migrate.exe

Is it possible to run ef migration from dll-containing migrations and dbcontext? I would like to run dotnet ef database update against my build artifacts without the need for project.json and source code.

In other words, I'm looking for the equivalent of migrate.exe https://msdn.microsoft.com/en-us/data/jj618307.aspx from EF6

+5
source share
2 answers

My colleague found a way to run migrations on assembly artifacts without sources. Following the 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 
+3
source

It is not possible to run dotnet ef database update only using the DLL, and if you are using docker, the actual version of runtime microsoft/dotnet:1.1.0-preview1-runtime does not have sdk installed (with the dotnet ef database update command).

One option for updating a database without using dotnet ef database update is to run the command below in some default actions or at startup.

 _dbContext.Database.Migrate(); 
+1
source

Source: https://habr.com/ru/post/1258328/


All Articles