efcore icon indicating copy to clipboard operation
efcore copied to clipboard

Add a pubternal way to clear ServiceProviderCache

Open AndriySvyryd opened this issue 3 years ago • 6 comments

As a workaround for issues like #27169

AndriySvyryd avatar Jan 14 '22 17:01 AndriySvyryd

Is this still a priority?

MeWagh avatar Jun 13 '22 18:06 MeWagh

@MeWagh It was never a priority. See release planning for information on how we decide what to work on.

ajcvickers avatar Jun 13 '22 18:06 ajcvickers

Understood, thanks.

MeWagh avatar Jun 13 '22 18:06 MeWagh

Hello can I take this issue?

BekAllaev avatar Jun 29 '22 16:06 BekAllaev

This impacts us as well. We rotate our NpgsqlDataSource every 12 hours. Even though we properly Dispose the old data sources and DbContext's, we eventually get:

'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.

Is there any way at all to get EF core to remove the old service providers?

gbd3-en avatar Feb 15 '24 16:02 gbd3-en

@gbd3-en the plan on the EFCore.PG side is to stop creating new EF service providers for different NpgsqlDataSources - that should take care of your usecase (see https://github.com/npgsql/efcore.pg/issues/3086).

roji avatar Feb 15 '24 17:02 roji