Share via


RelationalConnection.SetDbConnection(DbConnection, Boolean) Method

Definition

Sets the underlying DbConnection used to connect to the database.

public virtual void SetDbConnection (System.Data.Common.DbConnection? value, bool contextOwnsConnection);
abstract member SetDbConnection : System.Data.Common.DbConnection * bool -> unit
override this.SetDbConnection : System.Data.Common.DbConnection * bool -> unit
Public Overridable Sub SetDbConnection (value As DbConnection, contextOwnsConnection As Boolean)

Parameters

value
DbConnection

The connection object.

contextOwnsConnection
Boolean

If true, then EF will take ownership of the connection and will dispose it in the same way it would dispose a connection created by EF. If false, then the caller still owns the connection and is responsible for its disposal.

Implements

Applies to