RelationalDatabaseFacadeExtensions.GetDbConnection(DatabaseFacade) Method

Definition

Gets the underlying ADO.NET DbConnection for this DbContext.

public static System.Data.Common.DbConnection GetDbConnection (this Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade databaseFacade);
static member GetDbConnection : Microsoft.EntityFrameworkCore.Infrastructure.DatabaseFacade -> System.Data.Common.DbConnection
<Extension()>
Public Function GetDbConnection (databaseFacade As DatabaseFacade) As DbConnection

Parameters

databaseFacade
DatabaseFacade

The DatabaseFacade for the context.

Returns

The DbConnection

Remarks

This connection should not be disposed if it was created by Entity Framework. Connections are created by Entity Framework when a connection string rather than a DbConnection object is passed to the 'UseMyProvider' method for the database provider in use. Conversely, the application is responsible for disposing a DbConnection passed to Entity Framework in 'UseMyProvider'.

See Connections and connection strings for more information and examples.

Applies to