DbContext Constructor (DbConnection, Boolean)

[This page is specific to the Entity Framework version 6. The latest version is available as the 'Entity Framework' NuGet package. For more information about Entity Framework, see msdn.com/data/ef.]

Constructs a new context instance using the existing connection to connect to a database. The connection will not be disposed when the context is disposed if contextOwnsConnection is false.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public DbContext(
	DbConnection existingConnection,
	bool contextOwnsConnection


Type: System.Data.Common.DbConnection
An existing connection to use for the new context.
Type: System.Boolean
If set to true the connection is disposed when the context is disposed, otherwise the caller must dispose the connection.