EF Core - 无源运行迁移 - 等效于 EF6 的 migrate.exe [英] EF Core - Running migrations without sources - Equivalent of EF6's migrate.exe
问题描述
是否可以从包含迁移和 dbcontext 的 DLL 运行 ef 迁移?我想针对我的构建工件运行 dotnet ef database update
,而无需 project.json 和源代码.
Is it possible to run an ef migration from DLL containing migrations and dbcontext? I'd like to run dotnet ef database update
against my build artefacts without need of project.json and source codes.
换句话说,我正在寻找等效的 migrate.exe
https://msdn.microsoft.com/en-us/data/jj618307.aspx 来自 EF6
In other words I'm looking for an equivalent of migrate.exe
https://msdn.microsoft.com/en-us/data/jj618307.aspx from EF6
推荐答案
我的团队同事找到了一种方法,允许您在没有源的情况下对构建工件运行迁移.以下命令为我们替换 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
2.1.x 版本更新:
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 ./
这篇关于EF Core - 无源运行迁移 - 等效于 EF6 的 migrate.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!