Export (0) Print
Expand All

DbCompiledModel.CreateObjectContext<TContext> Method

Entity Framework 5.0

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.

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

public TContext CreateObjectContext<TContext>(
	DbConnection existingConnection
)
where TContext : ObjectContext

Type Parameters

TContext

The type of context to create.

Parameters

existingConnection
Type: System.Data.Common.DbConnection

An existing connection to a database for use by the context.

Return Value

Type: TContext
Returns context.
Show:
© 2014 Microsoft