Share via


IRelationalConnection.SetDbConnection(DbConnection, Boolean) Method

Definition

Sets the underlying DbConnection used to connect to the database.

public void SetDbConnection (System.Data.Common.DbConnection? value, bool contextOwnsConnection);
abstract member SetDbConnection : System.Data.Common.DbConnection * bool -> unit
Public 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.

Remarks

The connection can only be changed when the existing connection, if any, is not open.

Applies to