IRelationalConnection.SetDbConnection(DbConnection, Boolean) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
Entity Framework