EF Core-无源运行迁移-相当于EF6的migration.exe [英] EF Core - Running migrations without sources - Equivalent of EF6's migrate.exe

查看:89
本文介绍了EF Core-无源运行迁移-相当于EF6的migration.exe的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从包含迁移和dbcontext的DLL运行ef迁移?我想针对我的构建工件运行 dotnet ef数据库更新,而无需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的migration.exe的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆