Table of Contents

Class RelationalOptionsExtension

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

Represents options managed by the relational database providers. These options are set using Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

Instances of this class are designed to be immutable. To change an option, call one of the 'With...' methods to obtain a new instance with the option changed.

public abstract class RelationalOptionsExtension : IDbContextOptionsExtension
Inheritance
RelationalOptionsExtension
Implements
IDbContextOptionsExtension
Inherited Members

Constructors

RelationalOptionsExtension()

Creates a new set of options with everything set to default values.

protected RelationalOptionsExtension()

RelationalOptionsExtension(RelationalOptionsExtension)

Called by a derived class constructor when implementing the Clone() method.

protected RelationalOptionsExtension(RelationalOptionsExtension copyFrom)

Parameters

copyFrom RelationalOptionsExtension

The instance that is being cloned.

Properties

CommandTimeout

The command timeout, or null if none has been set.

public virtual int? CommandTimeout { get; }

Property Value

int?

Connection

The DbConnection, or null if a connection string was used instead of the full connection object.

public virtual DbConnection Connection { get; }

Property Value

DbConnection

ConnectionString

The connection string, or null if a DbConnection was used instead of a connection string.

public virtual string ConnectionString { get; }

Property Value

string

ExecutionStrategyFactory

A factory for creating the default Microsoft.EntityFrameworkCore.Storage.IExecutionStrategy, or null if none has been configured.

public virtual Func<ExecutionStrategyDependencies, IExecutionStrategy> ExecutionStrategyFactory { get; }

Property Value

Func<ExecutionStrategyDependencies, IExecutionStrategy>

Info

Information/metadata about the extension.

public abstract DbContextOptionsExtensionInfo Info { get; }

Property Value

DbContextOptionsExtensionInfo

MaxBatchSize

The maximum number of statements that will be included in commands sent to the database during Microsoft.EntityFrameworkCore.DbContext.SaveChanges or null if none has been set.

public virtual int? MaxBatchSize { get; }

Property Value

int?

MigrationsAssembly

The name of the assembly that contains migrations, or null if none has been set.

public virtual string MigrationsAssembly { get; }

Property Value

string

MigrationsHistoryTableName

The table name to use for the migrations history table, or null if none has been set.

public virtual string MigrationsHistoryTableName { get; }

Property Value

string

MigrationsHistoryTableSchema

The schema to use for the migrations history table, or null if none has been set.

public virtual string MigrationsHistoryTableSchema { get; }

Property Value

string

MinBatchSize

The minimum number of statements that are needed for a multi-statement command sent to the database during Microsoft.EntityFrameworkCore.DbContext.SaveChanges or null if none has been set.

public virtual int? MinBatchSize { get; }

Property Value

int?

QuerySplittingBehavior

The QuerySplittingBehavior to use when loading related collections in a query.

public virtual QuerySplittingBehavior? QuerySplittingBehavior { get; }

Property Value

QuerySplittingBehavior?

UseRelationalNulls

Indicates whether or not 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 bool UseRelationalNulls { get; }

Property Value

bool

Methods

ApplyServices(IServiceCollection)

Adds the services required to make the selected options work. This is used when there is no external IServiceProvider and EF is maintaining its own service provider internally. This allows database providers (and other extensions) to register their required services when EF is creating an service provider.

public abstract void ApplyServices(IServiceCollection services)

Parameters

services IServiceCollection

The collection to add services to.

Clone()

Override this method in a derived class to ensure that any clone created is also of that class.

protected abstract RelationalOptionsExtension Clone()

Returns

RelationalOptionsExtension

A clone of this instance, which can be modified before being returned as immutable.

Extract(IDbContextOptions)

Finds an existing RelationalOptionsExtension registered on the given options or throws if none has been registered. This is typically used to find some relational configuration when it is known that a relational provider is being used.

public static RelationalOptionsExtension Extract(IDbContextOptions options)

Parameters

options IDbContextOptions

The context options to look in.

Returns

RelationalOptionsExtension

The extension.

Validate(IDbContextOptions)

Gives the extension a chance to validate that all options in the extension are valid. Most extensions do not have invalid combinations and so this will be a no-op. If options are invalid, then an exception should be thrown.

public virtual void Validate(IDbContextOptions options)

Parameters

options IDbContextOptions

The options being validated.

WithCommandTimeout(int?)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithCommandTimeout(int? commandTimeout)

Parameters

commandTimeout int?

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithConnection(DbConnection)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithConnection(DbConnection connection)

Parameters

connection DbConnection

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithConnectionString(string)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithConnectionString(string connectionString)

Parameters

connectionString string

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithDefaultWarningConfiguration(CoreOptionsExtension)

Adds default Microsoft.EntityFrameworkCore.WarningBehavior for relational events.

public static CoreOptionsExtension WithDefaultWarningConfiguration(CoreOptionsExtension coreOptionsExtension)

Parameters

coreOptionsExtension CoreOptionsExtension

The core options extension.

Returns

CoreOptionsExtension

The new core options extension.

WithExecutionStrategyFactory(Func<ExecutionStrategyDependencies, IExecutionStrategy>)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithExecutionStrategyFactory(Func<ExecutionStrategyDependencies, IExecutionStrategy> executionStrategyFactory)

Parameters

executionStrategyFactory Func<ExecutionStrategyDependencies, IExecutionStrategy>

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithMaxBatchSize(int?)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithMaxBatchSize(int? maxBatchSize)

Parameters

maxBatchSize int?

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithMigrationsAssembly(string)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithMigrationsAssembly(string migrationsAssembly)

Parameters

migrationsAssembly string

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithMigrationsHistoryTableName(string)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithMigrationsHistoryTableName(string migrationsHistoryTableName)

Parameters

migrationsHistoryTableName string

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithMigrationsHistoryTableSchema(string)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithMigrationsHistoryTableSchema(string migrationsHistoryTableSchema)

Parameters

migrationsHistoryTableSchema string

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithMinBatchSize(int?)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithMinBatchSize(int? minBatchSize)

Parameters

minBatchSize int?

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithUseQuerySplittingBehavior(QuerySplittingBehavior)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithUseQuerySplittingBehavior(QuerySplittingBehavior querySplittingBehavior)

Parameters

querySplittingBehavior QuerySplittingBehavior

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.

WithUseRelationalNulls(bool)

Creates a new instance with all options the same as for this instance, but with the given option changed. It is unusual to call this method directly. Instead use Microsoft.EntityFrameworkCore.DbContextOptionsBuilder.

public virtual RelationalOptionsExtension WithUseRelationalNulls(bool useRelationalNulls)

Parameters

useRelationalNulls bool

The option to change.

Returns

RelationalOptionsExtension

A new instance with the option changed.