Regression Fix - Update HostFactoryResolver, set the app name via an argument #60053
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Based on original PR: dotnet/efcore#26198
Dupe of PR: #59743
Fixes reported issue: #59745
Updates HostFactoryResolver to account for lack of application name with new host pattern and adds test.
Description
Changes to the templates for 6.0 required a new mechanism for tools to discover and use registered services in an ASP.NET Core or any other app based on a hosted service provider. This new mechanism results in a host setup that does not by default have an application name available. This in turn results in user secrets not being found, and so any tooling that is using user secrets will fail. This was discovered using EF Core which supports obtaining the database connection string from user secrets.
The fix is to set a default application name based on the assembly when using this new mechanism to discover services.
Customer impact
EF Core database operations executed from the command line may fail, or worse, use the wrong connection string and update the wrong database.
How found
Customer reported on RC1.
Regression
Yes and no. It's a regression to the experience when the new templates or the patterns shipped in those templates are used. It is not technically a regression if the application is still using the patterns from previous versions.
Testing
Testing is tricky here because this runtime package is consumed as source in EF Core. This is what we have done and plan to do:
Risk
Low. Simple code change to add a default application name on in the new code path introduced in 6.0.