c# - dotnet ef 核心列表永远不会完成
问题描述
通过 Azure Dev Ops 提交构建后,我们注意到构建迁移步骤的命令在一个小时不活动后超时。它只发生在这个分支上,我们已经成功完成了其他分支。该解决方案构建并成功运行。
经过调查,我将问题缩小到发生在以下命令上:
dotnet ef migrations list --configuration Release --project <repo_project_name> --startup-project <startup_project_name> --no-build --context <fully_qualified_context_class_name>
当我在 Powershell 中运行上述命令时,它在吐出项目中的迁移列表后,它只是挂起并且永远不会返回到提示符。
我已经看到其他类似问题的讨论建议删除 obj 文件夹,但是当我在启动项目文件夹中执行此操作时,我收到一条消息,指出它缺少 project.assets.json。(当我在 repo 项目文件夹中执行此操作时,它像以前一样挂起。但即使在本地解决了它,我怎么能在 ADO 服务器上实现它?
更奇怪的是,这个特定的分支甚至没有更新 repo 项目。
关于我应该如何进行的任何想法?谢谢。
更新:我已经能够缩小我们正在等待线程结束的范围。这是挂起点的调用堆栈:
System.Private.CoreLib.dll!System.Threading.WaitHandle.WaitOneNoCheck(int millisecondsTimeout)
System.Private.CoreLib.dll!System.Threading.WaitHandle.WaitOne(int millisecondsTimeout)
System.Diagnostics.Process.dll!System.Diagnostics.Process.WaitForExitCore(int milliseconds)
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.Exe.Run(string executable, System.Collections.Generic.IReadOnlyList<string> args, string workingDirectory, bool interceptOutput)
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.RootCommand.Execute()
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.Commands.CommandBase.Configure.AnonymousMethod__0()
dotnet-ef.dll!Microsoft.DotNet.Cli.CommandLine.CommandLineApplication.Execute(string[] args)
dotnet-ef.dll!Microsoft.EntityFrameworkCore.Tools.Program.Main(string[] args)
解决方案
The issue turned out to be a process we developed was not shutting down properly after script generation. The reason for that seems to be that "dotnet ef migrations" only does a partial startup of the website. It calls Startup.ConfigureServices but not Startup.Configure, which is where web shutdown functions are configured, so I'm theorizing that Dispose methods don't get called properly, resulting in our process not shutting down correctly.
I worked around that by implementing the suggestion found in this answer to another question.
推荐阅读
- c++ - 有没有办法覆盖 Font.Position 增量以使它们更小(小于 5 pt)?使用 VBA 还是其他方式?
- javascript - 在新标签页中打开链接,抓取,转到上一页
- django - 在本地运行服务器时,RelatedObjectDoesNotExist 在 /login/
- javascript - 为什么我的闭包内的函数效果不持久?
- c# - 试图在 C# 中查找元素我做错了什么
- ios - 如何从我的标题中删除重复的空格?
- c# - ASP.NET MVC 5:在整个会话中保持共享视图单选按钮选择/值
- php - 如何将 symfony 应用程序连接到 Azure redis 缓存?
- google-cloud-platform - 无法在 Google Cloud Platform 上创建基于 GPU 的 VM 实例
- javascript - null 不是对象(评估“_reactNativeSettings.default.getSetting”)?