Table of Contents

Class RelationalDbContextOptionsBuilder<TBuilder, TExtension>

Namespace
Microsoft.EntityFrameworkCore.Infrastructure
Assembly
Microsoft.EntityFrameworkCore.Relational.dll

Allows relational database specific configuration to be performed on Microsoft.EntityFrameworkCore.DbContextOptions.

Instances of this class are typically returned from methods that configure the context to use a particular relational database provider.

public abstract class RelationalDbContextOptionsBuilder<TBuilder, TExtension> : IRelationalDbContextOptionsBuilderInfrastructure where TBuilder : RelationalDbContextOptionsBuilder<TBuilder, TExtension> where TExtension : RelationalOptionsExtension, new()

Type Parameters

TBuilder
TExtension
Inheritance
RelationalDbContextOptionsBuilder<TBuilder, TExtension>
Implements
Inherited Members

Constructors

RelationalDbContextOptionsBuilder(DbContextOptionsBuilder)

Initializes a new instance of the RelationalDbContextOptionsBuilder<TBuilder, TExtension> class.

protected RelationalDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)

Parameters

optionsBuilder DbContextOptionsBuilder

The core options builder.

Properties

OptionsBuilder

Gets the core options builder.

protected virtual DbContextOptionsBuilder OptionsBuilder { get; }

Property Value

DbContextOptionsBuilder

Methods

CommandTimeout(int?)

Configures the wait time (in seconds) before terminating the attempt to execute a command and generating an error.

public virtual TBuilder CommandTimeout(int? commandTimeout)

Parameters

commandTimeout int?

The time in seconds to wait for the command to execute.

Returns

TBuilder

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

ExecutionStrategy(Func<ExecutionStrategyDependencies, IExecutionStrategy>)

Configures the context to use the provided Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy.

public virtual TBuilder ExecutionStrategy(Func<ExecutionStrategyDependencies, IExecutionStrategy> getExecutionStrategy)

Parameters

getExecutionStrategy Func<ExecutionStrategyDependencies, IExecutionStrategy>

A function that returns a new instance of an execution strategy.

Returns

TBuilder

MaxBatchSize(int)

Configures the maximum number of statements that will be included in commands sent to the database during Microsoft.EntityFrameworkCore.DbContext.SaveChanges.

public virtual TBuilder MaxBatchSize(int maxBatchSize)

Parameters

maxBatchSize int

The maximum number of statements.

Returns

TBuilder

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

MigrationsAssembly(string)

Configures the assembly where migrations are maintained for this context.

public virtual TBuilder MigrationsAssembly(string assemblyName)

Parameters

assemblyName string

The name of the assembly.

Returns

TBuilder

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

MigrationsHistoryTable(string, string)

Configures the name of the table used to record which migrations have been applied to the database.

public virtual TBuilder MigrationsHistoryTable(string tableName, string schema = null)

Parameters

tableName string

The name of the table.

schema string

The schema of the table.

Returns

TBuilder

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

MinBatchSize(int)

Configures the minimum number of statements that are needed for a multi-statement command sent to the database during Microsoft.EntityFrameworkCore.DbContext.SaveChanges.

public virtual TBuilder MinBatchSize(int minBatchSize)

Parameters

minBatchSize int

The minimum number of statements.

Returns

TBuilder

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

UseQuerySplittingBehavior(QuerySplittingBehavior)

Configures the QuerySplittingBehavior to use when loading related collections in a query.

public virtual TBuilder UseQuerySplittingBehavior(QuerySplittingBehavior querySplittingBehavior)

Parameters

querySplittingBehavior QuerySplittingBehavior

Returns

TBuilder

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

UseRelationalNulls(bool)

Configures the context to use relational database semantics when comparing null values. By default, Entity Framework will use C# semantics for null values, and generate SQL to compensate for differences in how the database handles nulls.

public virtual TBuilder UseRelationalNulls(bool useRelationalNulls = true)

Parameters

useRelationalNulls bool

Returns

TBuilder

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

WithOption(Func<TExtension, TExtension>)

Sets an option by cloning the extension used to store the settings. This ensures the builder does not modify options that are already in use elsewhere.

protected virtual TBuilder WithOption(Func<TExtension, TExtension> setAction)

Parameters

setAction Func<TExtension, TExtension>

An action to set the option.

Returns

TBuilder

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