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.
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
Remarks
Instances of this class are typically returned from methods that configure the context to use a particular relational database provider.
See Using DbContextOptions for more information and examples.
Constructors
RelationalDbContextOptionsBuilder(DbContextOptionsBuilder)
Initializes a new instance of the RelationalDbContextOptionsBuilder<TBuilder, TExtension> class.
protected RelationalDbContextOptionsBuilder(DbContextOptionsBuilder optionsBuilder)
Parameters
optionsBuilder
DbContextOptionsBuilderThe 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.
Remarks
This sets the CommandTimeout property on the ADO.NET provider being used.
An ArgumentException is generated if commandTimeout
value is less than 0.
Zero (0) typically means no timeout will be applied, consult your ADO.NET provider documentation.
See Connections and connection strings for more information and examples.
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
Remarks
See Connection resiliency and database retries for more information and examples.
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
intThe maximum number of statements.
Returns
- TBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Saving data with EF Core for more information and examples.
MigrationsAssembly(string?)
Configures the assembly where migrations are maintained for this context.
public virtual TBuilder MigrationsAssembly(string? assemblyName)
Parameters
assemblyName
stringThe name of the assembly.
Returns
- TBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Database migrations for more information and examples.
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
Returns
- TBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Database migrations for more information and examples.
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
intThe minimum number of statements.
Returns
- TBuilder
The same builder instance so that multiple calls can be chained.
Remarks
See Saving data with EF Core for more information and examples.
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.
Remarks
See EF Core split queries for more information and examples.
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.
Remarks
See Relational database null semantics for more information and examples.
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.