-
Notifications
You must be signed in to change notification settings - Fork 5k
Binding NpgsqlConnectionStringBuilder to configuration does not work on .net 7.0 #78908
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Tagging subscribers to this area: @dotnet/area-extensions-configuration Issue DetailsDescriptionI'm used to bind an instance of NpgsqlConnectionStringBuilder (from Npgsql) to the configuration during startup, but this does not work anymore after upgrading to .net 7.0: The instance remains empty and values are not loaded from configuration Reproduction Steps
Add
If you Expected behaviorThe configuration data is loaded and mapped to the instance passed to Actual behaviorThe configuration data is not loaded and the instance passed to Regression?Yes, this worked on .net 6.0, at least up to 6.0.10. Known WorkaroundsNo direct workaraoud, it's necessary to use a POCO to bind from configuration. Configuration.NET 7.0 Other informationThe problem might be in changes to configuration binder, considering that
|
This is fixed and should be released in the next service release of .NET 7.0. If you are interested to try the fix from now, you may add the following nuget feed <add key="dotnet8" value="https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet8/nuget/v3/index.json" /> and the use package version like |
I can confirm, with 8.0.0-alpha.1.22578.1 the problem is solved. |
Description
I'm used to bind an instance of NpgsqlConnectionStringBuilder (from Npgsql) to the configuration during startup, but this does not work anymore after upgrading to .net 7.0: The instance remains empty and values are not loaded from configuration
Reproduction Steps
Add
appsettings.json
file with this content:If you
dotnet run
, the program crashes due to the last assertion: the values are not loaded from configuration.If the project is downgraded to .net6.0 (and also the deps), the program runs ok, the values are correctly loaded.
I think it's not a direct problem of Npgsql, but something related to a change in .net7 that is not compatible with internal mappings used by NpgsqlConnectionStringBuilder.
A direct binding to a POCO runs like a charm, but with NpgsqlConnectionStringBuilder no.
Expected behavior
The configuration data is loaded and mapped to the instance passed to
Bind
.Actual behavior
The configuration data is not loaded and the instance passed to
Bind
reamins empty.Regression?
Yes, this worked on .net 6.0, at least up to 6.0.10.
Known Workarounds
No direct workaraoud, it's necessary to use a POCO to bind from configuration.
Configuration
.NET 7.0
Window 11 Pro x64
Other information
The problem might be in changes to configuration binder, considering that
NpgsqlConnectionStringBuilder
exposes properties but also aIDictionary<string, object?>
.The text was updated successfully, but these errors were encountered: