Class DbContextOptions
- Namespace
- Microsoft.EntityFrameworkCore
- Assembly
- Microsoft.EntityFrameworkCore.dll
The options to be used by a DbContext. You normally override OnConfiguring(DbContextOptionsBuilder) or use a DbContextOptionsBuilder to create instances of this class and it is not designed to be directly constructed in your application code.
public abstract class DbContextOptions : IDbContextOptions
- Inheritance
-
DbContextOptions
- Implements
- Derived
- Inherited Members
- Extension Methods
Remarks
See Using DbContextOptions for more information and examples.
Constructors
DbContextOptions()
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
[EntityFrameworkInternal]
protected DbContextOptions()
DbContextOptions(IReadOnlyDictionary<Type, IDbContextOptionsExtension>)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
[EntityFrameworkInternal]
protected DbContextOptions(IReadOnlyDictionary<Type, IDbContextOptionsExtension> extensions)
Parameters
extensions
IReadOnlyDictionary<Type, IDbContextOptionsExtension>
DbContextOptions(ImmutableSortedDictionary<Type, (IDbContextOptionsExtension Extension, int Ordinal)>)
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
[EntityFrameworkInternal]
protected DbContextOptions(ImmutableSortedDictionary<Type, (IDbContextOptionsExtension Extension, int Ordinal)> extensions)
Parameters
extensions
ImmutableSortedDictionary<Type, (IDbContextOptionsExtension Extension, int Ordinal)>
Properties
ContextType
The type of context that these options are for. Will return DbContext if the options are not built for a specific derived context.
public abstract Type ContextType { get; }
Property Value
Extensions
Gets the extensions that store the configured options.
public virtual IEnumerable<IDbContextOptionsExtension> Extensions { get; }
Property Value
ExtensionsMap
This is an internal API that supports the Entity Framework Core infrastructure and not subject to the same compatibility standards as public APIs. It may be changed or removed without notice in any release. You should only use it directly in your code with extreme caution and knowing that doing so can result in application failures when updating to a new Entity Framework Core release.
[EntityFrameworkInternal]
protected virtual ImmutableSortedDictionary<Type, (IDbContextOptionsExtension Extension, int Ordinal)> ExtensionsMap { get; }
Property Value
IsFrozen
Returns true if Freeze() has been called. A frozen options object cannot be further configured with OnConfiguring(DbContextOptionsBuilder).
public virtual bool IsFrozen { get; }
Property Value
Methods
Equals(DbContextOptions)
Determines whether the specified object is equal to the current object.
protected virtual bool Equals(DbContextOptions other)
Parameters
other
DbContextOptionsThe object to compare with the current object.
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
obj
object
Returns
FindExtension<TExtension>()
Gets the extension of the specified type. Returns null if no extension of the specified type is configured.
public virtual TExtension? FindExtension<TExtension>() where TExtension : class, IDbContextOptionsExtension
Returns
- TExtension
The extension, or null if none was found.
Type Parameters
TExtension
The type of the extension to get.
Freeze()
Specifies that no further configuration of this options object should occur.
public virtual void Freeze()
GetExtension<TExtension>()
Gets the extension of the specified type. Throws if no extension of the specified type is configured.
public virtual TExtension GetExtension<TExtension>() where TExtension : class, IDbContextOptionsExtension
Returns
- TExtension
The extension.
Type Parameters
TExtension
The type of the extension to get.
GetHashCode()
public override int GetHashCode()
Returns
WithExtension<TExtension>(TExtension)
Adds the given extension to the underlying options and creates a new DbContextOptions with the extension added.
public abstract DbContextOptions WithExtension<TExtension>(TExtension extension) where TExtension : class, IDbContextOptionsExtension
Parameters
extension
TExtensionThe extension to be added.
Returns
- DbContextOptions
The new options instance with the given extension added.
Type Parameters
TExtension
The type of extension to be added.