DbContextOptions DbContextOptions Class

Definition

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
Public MustInherit Class DbContextOptions
    Implements IDbContextOptions
Inheritance
System.ObjectSystem.Object
DbContextOptionsDbContextOptions
Implements

Inherited Members

System.Object

System.Object.ToString()System.Object.ToString()
System.Object.Equals(System.Object)System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()System.Object.GetHashCode()
System.Object.GetType()System.Object.GetType()
System.Object.MemberwiseClone()System.Object.MemberwiseClone()

Constructors

DbContextOptions(IReadOnlyDictionary) DbContextOptions(IReadOnlyDictionary(Of Type, IDbContextOptionsExtension))

Initializes a new instance of the DbContextOptions class. 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.

protected DbContextOptions(IReadOnlyDictionary<Type, IDbContextOptionsExtension> extensions)
Protected Sub New(extensions As IReadOnlyDictionary(Of Type, IDbContextOptionsExtension))
Parameters
extensions
System.Collections.Generic.IReadOnlyDictionary<System.Type, IDbContextOptionsExtension> System.Collections.Generic.IReadOnlyDictionary(Of System.Type, IDbContextOptionsExtension)

The extensions that store the configured options.

Properties

ContextType 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; }
Public MustOverride ReadOnly Property ContextType As Type
Value
System.Type System.Type

Extensions Extensions

Gets the extensions that store the configured options.

public virtual IEnumerable<IDbContextOptionsExtension> Extensions { get; }
Public Overridable ReadOnly Property Extensions As IEnumerable(Of IDbContextOptionsExtension)
Value
System.Collections.Generic.IEnumerable<IDbContextOptionsExtension> System.Collections.Generic.IEnumerable(Of IDbContextOptionsExtension)

Methods

FindExtension() FindExtension(Of 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
Public Overridable Function FindExtension(Of TExtension As {Class, IDbContextOptionsExtension}) As TExtension
Type Parameters
TExtension

The type of the extension to get.

Returns
TExtension TExtension

The extension, or null if none was found.

GetExtension() GetExtension(Of 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
Public Overridable Function GetExtension(Of TExtension As {Class, IDbContextOptionsExtension}) As TExtension
Type Parameters
TExtension

The type of the extension to get.

Returns
TExtension TExtension

The extension.

WithExtension(TExtension) WithExtension(Of TExtension)(TExtension)

Adds the given extension to the options.

public abstract DbContextOptions WithExtension<TExtension>(TExtension extension)where TExtension : class, IDbContextOptionsExtension
Public MustOverride Function WithExtension(Of TExtension As {Class, IDbContextOptionsExtension})(extension As TExtension) As DbContextOptions
Type Parameters
TExtension

The type of extension to be added.

Parameters
extension
TExtension TExtension

The extension to be added.

Returns

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