title: Why does "dotnet ef migrations add" start my application?
body: <p>I've created a new project using .NET 6 and EF Core 6 but when I try to create a migration using <code>dotnet ef migrations add</code>, the CLI begins running the application after &quot;Build succeeded.&quot;.</p>
  <p>This isn't preventing the migrations from being created but adds a considerable amount of time to the process as I need to wait for the application to exit before issuing any other commands.</p>
  <p>Snippet of dotnet ef migrations add output:</p>
  <p><a href="https://i.stack.imgur.com/ooJCs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ooJCs.png" alt="snippet of dotnet ef migrations add output" /></a></p>
  <p>Within the same solution I have many other projects using .NET 5 and EF Core 5 which all create migrations as expected (just builds the project, doesn't run it).</p>
  <p>Is this new functionality for EF Core 6 or is there a configuration somewhere which would cause this behaviour?</p>
  <p><strong>EDIT</strong></p>
  <p>It seems like the issue is EF Core ignoring implimentations of IDesignTimeDbContext factory during migration creation and instead defaults to obtaining an instance of the DbContext from the host builder. Apparently can also happen with EF Core 5.</p>
  <p>There is an open issue on the dotnet/efcore github here: <a href="https://github.com/dotnet/efcore/issues/25053" rel="nofollow noreferrer">Migrations script not using IDesignTimeDbContextFactory</a></p>