Note

Access to this page requires authorization. You can try signing in or .

Access to this page requires authorization. You can try .

DbContextOptions Class

Definition

Namespace:
Microsoft.EntityFrameworkCore
Assembly:
Microsoft.EntityFrameworkCore.dll
Package:
Microsoft.EntityFrameworkCore v1.0.6
Package:
Microsoft.EntityFrameworkCore v1.1.6
Package:
Microsoft.EntityFrameworkCore v10.0.0
Package:
Microsoft.EntityFrameworkCore v2.0.3
Package:
Microsoft.EntityFrameworkCore v2.1.11
Package:
Microsoft.EntityFrameworkCore v2.2.6
Package:
Microsoft.EntityFrameworkCore v3.0.0
Package:
Microsoft.EntityFrameworkCore v3.1.0
Package:
Microsoft.EntityFrameworkCore v5.0.0
Package:
Microsoft.EntityFrameworkCore v6.0.0
Package:
Microsoft.EntityFrameworkCore v7.0.0
Package:
Microsoft.EntityFrameworkCore v8.0.0
Package:
Microsoft.EntityFrameworkCore v9.0.0
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs
Source:
DbContextOptions.cs

Important

Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.

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 : Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptions
[System.Runtime.CompilerServices.Nullable(0)]
public abstract class DbContextOptions : Microsoft.EntityFrameworkCore.Infrastructure.IDbContextOptions
type DbContextOptions = class
 interface IDbContextOptions
[<System.Runtime.CompilerServices.Nullable(0)>]
type DbContextOptions = class
 interface IDbContextOptions
Public MustInherit Class DbContextOptions
Implements IDbContextOptions
Inheritance
DbContextOptions
Derived
Attributes
Implements

Remarks

See Using DbContextOptions for more information and examples.

Constructors

Name Description
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.

DbContextOptions(ImmutableSortedDictionary<Type,ValueTuple<IDbContextOptionsExtension,Int32>>)

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.

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.

Properties

Name Description
ContextType

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

Extensions

Gets the extensions that store the configured options.

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.

IsFrozen

Returns true if Freeze() has been called. A frozen options object cannot be further configured with OnConfiguring(DbContextOptionsBuilder).

Methods

Name Description
Equals(DbContextOptions)

Determines whether the specified object is equal to the current object.

Equals(Object)

Determines whether the specified object is equal to the current object.

FindExtension<TExtension>()

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

Freeze()

Specifies that no further configuration of this options object should occur.

GetExtension<TExtension>()

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

GetHashCode()

Serves as the default hash function.

WithExtension<TExtension>(TExtension)

Adds the given extension to the underlying options and creates a new DbContextOptions with the extension added.

Applies to


Feedback

Was this page helpful?