SqlServerDbContextOptionsExtensions SqlServerDbContextOptionsExtensions Class

Definition

SQL Server specific extension methods for DbContextOptionsBuilder.

public static class SqlServerDbContextOptionsExtensions
Public Module SqlServerDbContextOptionsExtensions
Inheritance
System.ObjectSystem.Object
SqlServerDbContextOptionsExtensionsSqlServerDbContextOptionsExtensions

Inherited Members

System.Object

System.Object.ToString()System.Object.ToString()
System.Object.Equals(System.Object)System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()System.Object.GetHashCode()
System.Object.GetType()System.Object.GetType()
System.Object.MemberwiseClone()System.Object.MemberwiseClone()

Methods

UseSqlServer(DbContextOptionsBuilder, DbConnection, Action) UseSqlServer(DbContextOptionsBuilder, DbConnection, Action(Of SqlServerDbContextOptionsBuilder))

Configures the context to connect to a Microsoft SQL Server database.

public static DbContextOptionsBuilder UseSqlServer(this DbContextOptionsBuilder optionsBuilder, DbConnection connection, Action<SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null)
<ExtensionAttribute>
Public Shared Function UseSqlServer(optionsBuilder As DbContextOptionsBuilder, connection As DbConnection, sqlServerOptionsAction As Action(Of SqlServerDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder
Parameters
optionsBuilder
DbContextOptionsBuilder DbContextOptionsBuilder

The builder being used to configure the context.

connection
System.Data.Common.DbConnection System.Data.Common.DbConnection

An existing System.Data.Common.DbConnection to be used to connect to the database. If the connection is in the open state then EF will not open or close the connection. If the connection is in the closed state then EF will open and close the connection as needed.

sqlServerOptionsAction
System.Action<SqlServerDbContextOptionsBuilder> System.Action(Of SqlServerDbContextOptionsBuilder)

An optional action to allow additional SQL Server specific configuration.

Returns

The options builder so that further configuration can be chained.

UseSqlServer(DbContextOptionsBuilder, String, Action) UseSqlServer(DbContextOptionsBuilder, String, Action(Of SqlServerDbContextOptionsBuilder))

Configures the context to connect to a Microsoft SQL Server database.

public static DbContextOptionsBuilder UseSqlServer(this DbContextOptionsBuilder optionsBuilder, string connectionString, Action<SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null)
<ExtensionAttribute>
Public Shared Function UseSqlServer(optionsBuilder As DbContextOptionsBuilder, connectionString As String, sqlServerOptionsAction As Action(Of SqlServerDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder
Parameters
optionsBuilder
DbContextOptionsBuilder DbContextOptionsBuilder

The builder being used to configure the context.

connectionString
System.String System.String

The connection string of the database to connect to.

sqlServerOptionsAction
System.Action<SqlServerDbContextOptionsBuilder> System.Action(Of SqlServerDbContextOptionsBuilder)

An optional action to allow additional SQL Server specific configuration.

Returns

The options builder so that further configuration can be chained.

UseSqlServer(DbContextOptionsBuilder, DbConnection, Action) UseSqlServer(Of TContext)(DbContextOptionsBuilder(Of TContext), DbConnection, Action(Of SqlServerDbContextOptionsBuilder))

Configures the context to connect to a Microsoft SQL Server database.

public static DbContextOptionsBuilder<TContext> UseSqlServer<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, DbConnection connection, Action<SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null)where TContext : DbContext
<ExtensionAttribute>
Public Shared Function UseSqlServer(Of TContext As DbContext)(optionsBuilder As DbContextOptionsBuilder(Of TContext), connection As DbConnection, sqlServerOptionsAction As Action(Of SqlServerDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)
Type Parameters
TContext

The type of context to be configured.

Parameters
optionsBuilder
DbContextOptionsBuilder<TContext> DbContextOptionsBuilder(Of TContext)

The builder being used to configure the context.

connection
System.Data.Common.DbConnection System.Data.Common.DbConnection

An existing System.Data.Common.DbConnection to be used to connect to the database. If the connection is in the open state then EF will not open or close the connection. If the connection is in the closed state then EF will open and close the connection as needed.

sqlServerOptionsAction
System.Action<SqlServerDbContextOptionsBuilder> System.Action(Of SqlServerDbContextOptionsBuilder)

An optional action to allow additional SQL Server specific configuration.

Returns

The options builder so that further configuration can be chained.

UseSqlServer(DbContextOptionsBuilder, String, Action) UseSqlServer(Of TContext)(DbContextOptionsBuilder(Of TContext), String, Action(Of SqlServerDbContextOptionsBuilder))

Configures the context to connect to a Microsoft SQL Server database.

public static DbContextOptionsBuilder<TContext> UseSqlServer<TContext>(this DbContextOptionsBuilder<TContext> optionsBuilder, string connectionString, Action<SqlServerDbContextOptionsBuilder> sqlServerOptionsAction = null)where TContext : DbContext
<ExtensionAttribute>
Public Shared Function UseSqlServer(Of TContext As DbContext)(optionsBuilder As DbContextOptionsBuilder(Of TContext), connectionString As String, sqlServerOptionsAction As Action(Of SqlServerDbContextOptionsBuilder) = Nothing) As DbContextOptionsBuilder(Of TContext)
Type Parameters
TContext

The type of context to be configured.

Parameters
optionsBuilder
DbContextOptionsBuilder<TContext> DbContextOptionsBuilder(Of TContext)

The builder being used to configure the context.

connectionString
System.String System.String

The connection string of the database to connect to.

sqlServerOptionsAction
System.Action<SqlServerDbContextOptionsBuilder> System.Action(Of SqlServerDbContextOptionsBuilder)

An optional action to allow additional SQL Server specific configuration.

Returns

The options builder so that further configuration can be chained.