Skip to content

Npgsql.DependencyInjection package for DbDataSource DI integration #4503

@roji

Description

@roji

With DbDataSource coming in, we can add a new Npgsql.DependencyInjection nuget package to make the DI integration really nice:

serviceCollection.AddNpgsqlDataSource(
    "Host=localhost;Username=test;Password=test",
    builder => builder.ConfigureLogging(...));

This would register an NpgsqlDataSource (and DbDataSource) as singleton, and an NpgsqlConnection (and DbConnection) from that NpgsqlDataSource as Scoped (lifetimes could be tweaked via parameters).

Unfortunately AddNpgsql (without the DataSource suffix) is already taken by EF Core for minimal API config...

/cc @ajcvickers

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions