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