-
Notifications
You must be signed in to change notification settings - Fork 256
Milestone
Description
NpgsqlDataSource is currently registered as a singleton service; although this conceptually makes sense, it creates various issues:
- When automatically getting the data source from DI, there's no way in EF to include the data source instance in the decision-making on whether a new service provider is needed, causing interference between service providers (Using NpgsqlDataSource in DependencyInjection pollutes other containers #2891).
- In some multi-tenant and testing scenarios, it's desirable to use many data sources with potentially the same EF service provider. In the current situation, this requires lots of EF service providers, which triggers our "many service providers" warning.
The main thing blocking making NpgsqlDataSource scoped is the fact that we get enum mappings from it in NpgsqlTypeMappingSource, which is itself a singleton. We should stop doing that (#3063), at which point it should be easy to make NpgsqlDataSource scoped.
pinkfloydx33, gbd3-en, alienwareone, PaulusParssinen, prom3theu5 and 7 more