首页 > 解决方案 > 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)

标签: c#entity-framework-coreentity-framework-migrationsef-core-2.2

解决方案


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.


推荐阅读