DbContextOptions DbContextOptions Class

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.

Syntax

Declaration

public abstract class DbContextOptions : IDbContextOptionsPublic MustInherit Class DbContextOptions
    Implements IDbContextOptions

Inheritance Hierarchy

  • System.Object
    System.Object
  • DbContextOptions
    DbContextOptions

Inherited Members

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

Constructors summary

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.

Properties summary

The type of context that these options are for. Will return DbContext if the options are not built for a specific derived context.

Gets the extensions that store the configured options.

Methods summary

Gets the extension of the specified type. Returns null if no extension of the specified type is configured.

Gets the extension of the specified type. Throws if no extension of the specified type is configured.

Adds the given extension to the options.

Constructors

  • DbContextOptions(IReadOnlyDictionary<Type, IDbContextOptionsExtension>)
    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<TKey, TValue><System.Type, IDbContextOptionsExtension>
      System.Collections.Generic.IReadOnlyDictionary<TKey, TValue>(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

    Property 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)

    Property Value

Methods

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

    Returns

    • TExtension
      TExtension

      The extension, or null if none was found.

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

    Returns

    • TExtension
      TExtension

      The extension.

  • WithExtension<TExtension>(TExtension)
    WithExtension(Of TExtension)(TExtension)

    Adds the given extension to the options.

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

    Parameters

    • extension
      TExtension
      TExtension

      The extension to be added.

    Returns

Details

Assembly

Microsoft.EntityFrameworkCore.dll