dotnet ef core list never completes

260 views Asked by At

After submitting a build though Azure Dev Ops, we noticed that the command to build the migration steps timed out after an hour of inactivity. It only happened on this branch and we've completed others before and since successfully. The solution builds and runs successfully.

Upon investigating, I narrowed down the issue to happening on the following command:

dotnet ef migrations list --configuration Release --project <repo_project_name> --startup-project <startup_project_name> --no-build --context <fully_qualified_context_class_name>

When I run the above command in Powershell,it after spitting out the list of migrations in the project, it just hangs and never returns to a prompt.

I've seen other discussions of similar issues suggesting to delete the obj folder, but when I do that in the startup project folder, I get a message that it's missing the project.assets.json. (When I do it in the repo project folder, it hangs as before. But even if that did resolve it locally, how could I implement that on the ADO server?

To make matters weirder, this particular branch didn't even update the repo project.

Any thoughts as to how I should proceed? Thanks.

UPDATE: I've been able to narrow down that we're waiting for a thread to end. This is the call stack at the point where it's hanging:

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)
1

There are 1 answers

0
Paul Smith Jr On BEST ANSWER

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.