Class CoreOptionsExtension
- Namespace
- Microsoft.EntityFrameworkCore.Infrastructure
- Assembly
- Microsoft.EntityFrameworkCore.dll
Represents options managed by the core of Entity Framework, as opposed to those managed by database providers or extensions. These options are set using DbContextOptionsBuilder.
Instances of this class are designed to be immutable. To change an option, call one of the 'With...' methods to obtain a new instance with the option changed.
public class CoreOptionsExtension : IDbContextOptionsExtension
- Inheritance
-
CoreOptionsExtension
- Implements
- Inherited Members
Remarks
See Implementation of database providers and extensions for more information and examples.
Constructors
CoreOptionsExtension()
Creates a new set of options with everything set to default values.
public CoreOptionsExtension()
CoreOptionsExtension(CoreOptionsExtension)
Called by a derived class constructor when implementing the Clone() method.
protected CoreOptionsExtension(CoreOptionsExtension copyFrom)
Parameters
copyFrom
CoreOptionsExtensionThe instance that is being cloned.
Properties
ApplicationServiceProvider
The option set from the UseApplicationServiceProvider(IServiceProvider?) method.
public virtual IServiceProvider? ApplicationServiceProvider { get; }
Property Value
AutoResolveRootProvider
The option set from the UseRootApplicationServiceProvider(IServiceProvider?) method.
public virtual bool AutoResolveRootProvider { get; }
Property Value
DbContextLogger
The option set from the LogTo(Action<string>, LogLevel, DbContextLoggerOptions?) method.
public virtual IDbContextLogger? DbContextLogger { get; }
Property Value
DetailedErrorsEnabled
The option set from the EnableDetailedErrors(bool) method.
public virtual bool DetailedErrorsEnabled { get; }
Property Value
Info
Information/metadata about the extension.
public virtual DbContextOptionsExtensionInfo Info { get; }
Property Value
Interceptors
The options set from the AddInterceptors(IEnumerable<IInterceptor>) method for scoped interceptors.
public virtual IEnumerable<IInterceptor>? Interceptors { get; }
Property Value
InternalServiceProvider
The option set from the UseInternalServiceProvider(IServiceProvider?) method.
public virtual IServiceProvider? InternalServiceProvider { get; }
Property Value
IsSensitiveDataLoggingEnabled
The option set from the EnableSensitiveDataLogging(bool) method.
public virtual bool IsSensitiveDataLoggingEnabled { get; }
Property Value
LoggerFactory
The option set from the UseLoggerFactory(ILoggerFactory?) method.
public virtual ILoggerFactory? LoggerFactory { get; }
Property Value
LoggingCacheTime
The option set from the AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, int) method.
public virtual TimeSpan LoggingCacheTime { get; }
Property Value
MaxPoolSize
The option set from the AddDbContextPool<TContext>(IServiceCollection, Action<DbContextOptionsBuilder>, int) method.
public virtual int? MaxPoolSize { get; }
Property Value
- int?
MemoryCache
The option set from the UseMemoryCache(IMemoryCache?) method.
public virtual IMemoryCache? MemoryCache { get; }
Property Value
Model
The option set from the UseModel(IModel) method.
public virtual IModel? Model { get; }
Property Value
QueryTrackingBehavior
The option set from the UseQueryTrackingBehavior(QueryTrackingBehavior) method.
public virtual QueryTrackingBehavior QueryTrackingBehavior { get; }
Property Value
ReplacedServices
The options set from the ReplaceService<TService, TImplementation>() method.
public virtual IReadOnlyDictionary<(Type, Type?), Type>? ReplacedServices { get; }
Property Value
- IReadOnlyDictionary<(Type, Type), Type>
RootApplicationServiceProvider
The option set from the UseRootApplicationServiceProvider(IServiceProvider?) method.
public virtual IServiceProvider? RootApplicationServiceProvider { get; }
Property Value
ServiceProviderCachingEnabled
The option set from the EnableServiceProviderCaching(bool) method.
public virtual bool ServiceProviderCachingEnabled { get; }
Property Value
SingletonInterceptors
The options set from the AddInterceptors(IEnumerable<IInterceptor>) method for singleton interceptors.
public virtual IEnumerable<ISingletonInterceptor>? SingletonInterceptors { get; }
Property Value
ThreadSafetyChecksEnabled
The option set from the EnableThreadSafetyChecks(bool) method.
public virtual bool ThreadSafetyChecksEnabled { get; }
Property Value
WarningsConfiguration
The options set from the ConfigureWarnings(Action<WarningsConfigurationBuilder>) method.
public virtual WarningsConfiguration WarningsConfiguration { get; }
Property Value
Methods
ApplyServices(IServiceCollection)
Adds the services required to make the selected options work. This is used when there is no external IServiceProvider and EF is maintaining its own service provider internally. This allows database providers (and other extensions) to register their required services when EF is creating an service provider.
public virtual void ApplyServices(IServiceCollection services)
Parameters
services
IServiceCollectionThe collection to add services to.
Clone()
Override this method in a derived class to ensure that any clone created is also of that class.
protected virtual CoreOptionsExtension Clone()
Returns
- CoreOptionsExtension
A clone of this instance, which can be modified before being returned as immutable.
Validate(IDbContextOptions)
Gives the extension a chance to validate that all options in the extension are valid. If options are invalid, then an exception will be thrown.
public virtual void Validate(IDbContextOptions options)
Parameters
options
IDbContextOptionsThe options being validated.
WithApplicationServiceProvider(IServiceProvider?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithApplicationServiceProvider(IServiceProvider? applicationServiceProvider)
Parameters
applicationServiceProvider
IServiceProviderThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithDbContextLogger(IDbContextLogger?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithDbContextLogger(IDbContextLogger? contextLogger)
Parameters
contextLogger
IDbContextLoggerThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithDetailedErrorsEnabled(bool)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithDetailedErrorsEnabled(bool detailedErrorsEnabled)
Parameters
detailedErrorsEnabled
boolThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithInterceptors(IEnumerable<IInterceptor>)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithInterceptors(IEnumerable<IInterceptor> interceptors)
Parameters
interceptors
IEnumerable<IInterceptor>The option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithInternalServiceProvider(IServiceProvider?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithInternalServiceProvider(IServiceProvider? internalServiceProvider)
Parameters
internalServiceProvider
IServiceProviderThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithLoggerFactory(ILoggerFactory?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithLoggerFactory(ILoggerFactory? loggerFactory)
Parameters
loggerFactory
ILoggerFactoryThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithLoggingCacheTime(TimeSpan)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithLoggingCacheTime(TimeSpan timeSpan)
Parameters
timeSpan
TimeSpanThe maximum time period over which to skip logging checks before checking again.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithMaxPoolSize(int?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithMaxPoolSize(int? maxPoolSize)
Parameters
maxPoolSize
int?The option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithMemoryCache(IMemoryCache?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithMemoryCache(IMemoryCache? memoryCache)
Parameters
memoryCache
IMemoryCacheThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithModel(IModel?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithModel(IModel? model)
Parameters
model
IModelThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithQueryTrackingBehavior(QueryTrackingBehavior)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithQueryTrackingBehavior(QueryTrackingBehavior queryTrackingBehavior)
Parameters
queryTrackingBehavior
QueryTrackingBehaviorThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithReplacedService(Type, Type, Type?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithReplacedService(Type serviceType, Type newImplementationType, Type? currentImplementationType = null)
Parameters
serviceType
TypeThe service contract.
newImplementationType
TypeThe implementation type to use for the service.
currentImplementationType
TypeThe specific existing implementation type to replace.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithRootApplicationServiceProvider(bool)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithRootApplicationServiceProvider(bool autoResolve = true)
Parameters
autoResolve
boolThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithRootApplicationServiceProvider(IServiceProvider?)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithRootApplicationServiceProvider(IServiceProvider? rootApplicationServiceProvider)
Parameters
rootApplicationServiceProvider
IServiceProviderThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithSensitiveDataLoggingEnabled(bool)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithSensitiveDataLoggingEnabled(bool sensitiveDataLoggingEnabled)
Parameters
sensitiveDataLoggingEnabled
boolThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithServiceProviderCachingEnabled(bool)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithServiceProviderCachingEnabled(bool serviceProviderCachingEnabled)
Parameters
serviceProviderCachingEnabled
boolThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithSingletonInterceptors(IEnumerable<ISingletonInterceptor>)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithSingletonInterceptors(IEnumerable<ISingletonInterceptor> interceptors)
Parameters
interceptors
IEnumerable<ISingletonInterceptor>The option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithThreadSafetyChecksEnabled(bool)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithThreadSafetyChecksEnabled(bool checksEnabled)
Parameters
checksEnabled
boolThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.
WithWarningsConfiguration(WarningsConfiguration)
Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use DbContextOptionsBuilder.
public virtual CoreOptionsExtension WithWarningsConfiguration(WarningsConfiguration warningsConfiguration)
Parameters
warningsConfiguration
WarningsConfigurationThe option to change.
Returns
- CoreOptionsExtension
A new instance with the option changed.