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
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.
The text was updated successfully, but these errors were encountered:
Excellent! We're in that multi-tenant scenario. Despite careful re-use & disposal of the NpgsqlDataSoruce and DbContext instances, we still end up with that ManyServiceProvidersCreatedWarning error.
Here is the full error in case it helps others searching for solutions:
'Microsoft.EntityFrameworkCore.Infrastructure.ManyServiceProvidersCreatedWarning':
More than twenty 'IServiceProvider' instances have been created for internal use by Entity Framework. This is commonly caused by injection of a new singleton service instance into every DbContext instance.
NpgsqlDataSource is currently registered as a singleton service; although this conceptually makes sense, it creates various issues:
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.
The text was updated successfully, but these errors were encountered: