You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Merge Npgsql.DependencyInjection into Npgsql #6590
Npgsql.DependencyInjection was added in 2022 in #4521.
The reasons for making its own package were not elucidated in that PR but I would guess it was either to minimize dependencies in Npgsql or avoid incompatibility with other TFMs it supported.
Npgsql now depends on Microsoft.Extensions.Logging.Abstractions which brings in Microsoft.Extensions.DependencyInjection.Abstractions. Both packages also require .NET 8.0 and higher. So there is no practical reason why the code couldn't be moved into Npgsql.
Making the DI types available in the base Npgsql package would simplify the usage story for consumers, who would get access to the DI helpers simply by installing Npgsql.
Two migration approaches I can think of:
Move NpgsqlServiceCollectionExtensions.cs and NpgsqlServiceCollectionExtensions.Obsolete.cs to Npgsql and add [assembly:TypeForwardedTo] to Npgsql.DependencyInjection; this has the downside of preserving obsolete methods.
Add NpgsqlServiceCollectionExtensions.cs (just the non-obsolete methods) to Npgsql and turn all the method bodies in Npgsql.DependencyInjection into simple wrappers that delegate to the new implementation in Npgsql.
Or:
3. Move the code but don't update Npgsql.DependencyInjection at all, just mark it as deprecated in NuGet next time you ship a major version.
(Opening this issue because I'm facing the same situation in MySqlConnector mysql-net/MySqlConnector#1649 and I'm curious on your thoughts about merging DI support into the primary package.)
The reasons for making its own package were not elucidated in that PR but I would guess it was either to minimize dependencies in Npgsql
Yep, that's pretty much that.
Npgsql now depends on Microsoft.Extensions.Logging.Abstractions which brings in Microsoft.Extensions.DependencyInjection.Abstractions.
Microsoft.Extensions.Logging.Abstractions only started to depend on Microsoft.Extensions.DependencyInjection.Abstractions with .NET 8, while that package was added around .NET 6/7, which is an additional reason as to why things were like this.
Overall, sounds reasonable to move whatever we need to the main dll.
Activity
bgrainger commentedon May 25, 2026
(Opening this issue because I'm facing the same situation in MySqlConnector mysql-net/MySqlConnector#1649 and I'm curious on your thoughts about merging DI support into the primary package.)
vonzshik commentedon May 26, 2026
Yep, that's pretty much that.
Microsoft.Extensions.Logging.Abstractionsonly started to depend onMicrosoft.Extensions.DependencyInjection.Abstractionswith .NET 8, while that package was added around .NET 6/7, which is an additional reason as to why things were like this.Overall, sounds reasonable to move whatever we need to the main dll.
roji commentedon May 27, 2026
Yeah, this is mainly historical. I'll just merge this into the main package.