DbCompiledModel.CreateObjectContext<TContext> Method (DbConnection)
Creates an instance of ObjectContext or class derived from ObjectContext. Note that an instance of DbContext can be created instead by using the appropriate DbContext constructor. If a derived ObjectContext is used, then it must have a public constructor with a single EntityConnection parameter. The connection passed is used by the ObjectContext created, but is not owned by the context. The caller must dispose of the connection once the context has been disposed.
Assembly: EntityFramework (in EntityFramework.dll)
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")] public TContext CreateObjectContext<TContext>( DbConnection existingConnection ) where TContext : ObjectContext
Parameters
- existingConnection
-
Type:
System.Data.Common.DbConnection
An existing connection to a database for use by the context.
Type Parameters
- TContext
The type of context to create.