DbContextOptionsBuilder<TContext>.EnableServiceProviderCaching Method

Definition

Enables or disables caching of internal service providers. Disabling caching can massively impact performance and should only be used in testing scenarios that build many service providers for test isolation.

public virtual Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<TContext> EnableServiceProviderCaching (bool cacheServiceProvider = true);
override this.EnableServiceProviderCaching : bool -> Microsoft.EntityFrameworkCore.DbContextOptionsBuilder<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function EnableServiceProviderCaching (Optional cacheServiceProvider As Boolean = true) As DbContextOptionsBuilder(Of TContext)

Parameters

cacheServiceProvider
Boolean

If true, then the internal service provider is cached.

Returns

The same builder instance so that multiple calls can be chained.

Remarks

Note that if the application is setting the internal service provider through a call to UseInternalServiceProvider(IServiceProvider), then setting this option will have no effect.

See Using DbContextOptions for more information and examples.

Applies to