SqlServerDbContextOptionsBuilder Class

Definition

Allows SQL Server specific configuration to be performed on DbContextOptions.

public class SqlServerDbContextOptionsBuilder : Microsoft.EntityFrameworkCore.Infrastructure.RelationalDbContextOptionsBuilder<Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder,Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension>
public class SqlServerDbContextOptionsBuilder : Microsoft.EntityFrameworkCore.Infrastructure.RelationalDbContextOptionsBuilder<Microsoft.EntityFrameworkCore.Infrastructure.SqlServerDbContextOptionsBuilder,Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal.SqlServerOptionsExtension>
type SqlServerDbContextOptionsBuilder = class
    inherit RelationalDbContextOptionsBuilder<SqlServerDbContextOptionsBuilder, SqlServerOptionsExtension>
Public Class SqlServerDbContextOptionsBuilder
Inherits RelationalDbContextOptionsBuilder(Of SqlServerDbContextOptionsBuilder, SqlServerOptionsExtension)
Inheritance
RelationalDbContextOptionsBuilder<SqlServerDbContextOptionsBuilder,Microsoft.EntityFrameworkCore.Infrastructure.Internal.SqlServerOptionsExtension>
SqlServerDbContextOptionsBuilder
Inheritance
RelationalDbContextOptionsBuilder<SqlServerDbContextOptionsBuilder,Microsoft.EntityFrameworkCore.SqlServer.Infrastructure.Internal.SqlServerOptionsExtension>
SqlServerDbContextOptionsBuilder

Remarks

Instances of this class are returned from a call to SqlServerDbContextOptionsExtensions.UseSqlServer and it is not designed to be directly constructed in your application code.

Constructors

SqlServerDbContextOptionsBuilder(DbContextOptionsBuilder)

Initializes a new instance of the SqlServerDbContextOptionsBuilder class.

Properties

OptionsBuilder

Gets the core options builder.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)

Methods

CloneExtension()

Clones the configuration in this builder.

CloneExtension()

Clones the configuration in this builder.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
CommandTimeout(Nullable<Int32>)

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

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
EnableRetryOnFailure()

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure(ICollection<Int32>)

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure(Int32, TimeSpan, ICollection<Int32>)

Configures the context to use the default retrying IExecutionStrategy.

This strategy is specifically tailored to SQL Server (including SQL Azure). It is pre-configured with error numbers for transient errors that can be retried, but additional error numbers can also be supplied.

EnableRetryOnFailure(Int32, TimeSpan, IEnumerable<Int32>)

Configures the context to use the default retrying IExecutionStrategy.

EnableRetryOnFailure(Int32)

Configures the context to use the default retrying IExecutionStrategy.

ExecutionStrategy(Func<ExecutionStrategyContext,IExecutionStrategy>)

Configures the context to use the provided IExecutionStrategy.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
ExecutionStrategy(Func<ExecutionStrategyDependencies,IExecutionStrategy>)

Configures the context to use the provided IExecutionStrategy.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
MaxBatchSize(Int32)

Configures the maximum number of statements that will be included in commands sent to the database during SaveChanges().

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
MigrationsAssembly(String)

Configures the assembly where migrations are maintained for this context.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
MigrationsHistoryTable(String, String)

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

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
MinBatchSize(Int32)

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

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
SetOption(Action<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.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
UseAzureSqlDefaults(Boolean)

Configures the context to use defaults optimized for Azure SQL, including retries on errors.

UseCompatibilityLevel(Int32)

Sets the SQL Server compatibility level that EF Core will use when interacting with the database. This allows configuring EF Core to work with older (or newer) versions of SQL Server. Defaults to 160 (SQL Server 2022).

UseQuerySplittingBehavior(QuerySplittingBehavior)

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

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
UseRelationalNulls()

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.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
UseRelationalNulls(Boolean)

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.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)
UseRowNumberForPaging()

Use a ROW_NUMBER() in queries instead of OFFSET/FETCH. This method is backwards-compatible to SQL Server 2005.

UseRowNumberForPaging(Boolean)
Obsolete.

Use a ROW_NUMBER() in queries instead of OFFSET/FETCH. This method is backwards-compatible to SQL Server 2005.

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.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)

Explicit Interface Implementations

IRelationalDbContextOptionsBuilderInfrastructure.OptionsBuilder

Gets the core options builder.

(Inherited from RelationalDbContextOptionsBuilder<TBuilder,TExtension>)

Extension Methods

UseNetTopologySuite(SqlServerDbContextOptionsBuilder)

Use NetTopologySuite to access SQL Server spatial data.

Applies to