Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

ObjectContext Constructor

Entity Framework 6.0
 

Initializes a new instance of the ObjectContext class.

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

NameDescription
System_CAPS_pubmethodObjectContext(EntityConnection^)

Initializes a new instance of the ObjectContext class with the given connection. During construction, the metadata workspace is extracted from the EntityConnection object.

System_CAPS_pubmethodObjectContext(EntityConnection^, Boolean)

Creates an ObjectContext with the given connection and metadata workspace.

System_CAPS_protmethodObjectContext(EntityConnection^, String^)

Initializes a new instance of the ObjectContext class with a given connection and entity container name.

System_CAPS_pubmethodObjectContext(String^)

Initializes a new instance of the ObjectContext class with the given connection string and default entity container name.

System_CAPS_protmethodObjectContext(String^, String^)

Initializes a new instance of the ObjectContext class with a given connection string and entity container name.

Return to top

ObjectContext Constructor (EntityConnection^)

Initializes a new instance of the ObjectContext class with the given connection. During construction, the metadata workspace is extracted from the EntityConnection object.

public:
ObjectContext(
	EntityConnection^ connection
)

Parameters

connection
Type: System.Data.Entity.Core.EntityClient::EntityConnection^

An EntityConnection that contains references to the model and to the data source connection.

Exception Condition
ArgumentNullException

The connection is null.

ArgumentException

The connection is invalid or the metadata workspace is invalid.

Return to top

ObjectContext Constructor (EntityConnection^, Boolean)

Creates an ObjectContext with the given connection and metadata workspace.

public:
ObjectContext(
	EntityConnection^ connection,
	bool contextOwnsConnection
)

Parameters

connection
Type: System.Data.Entity.Core.EntityClient::EntityConnection^

connection to the store

contextOwnsConnection
Type: System::Boolean

If set to true the connection is disposed when the context is disposed, otherwise the caller must dispose the connection.

Return to top

ObjectContext Constructor (EntityConnection^, String^)

Initializes a new instance of the ObjectContext class with a given connection and entity container name.

protected:
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", 
	Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
ObjectContext(
	EntityConnection^ connection,
	String^ defaultContainerName
)

Parameters

connection
Type: System.Data.Entity.Core.EntityClient::EntityConnection^

An EntityConnection that contains references to the model and to the data source connection.

defaultContainerName
Type: System::String^

The name of the default entity container. When the defaultContainerName is set through this method, the property becomes read-only.

Exception Condition
ArgumentNullException

The connection is null.

ArgumentException

The connection , defaultContainerName , or metadata workspace is not valid.

Return to top

ObjectContext Constructor (String^)

Initializes a new instance of the ObjectContext class with the given connection string and default entity container name.

public:
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", 
	Justification = "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
ObjectContext(
	String^ connectionString
)

Parameters

connectionString
Type: System::String^

The connection string, which also provides access to the metadata information.

Exception Condition
ArgumentNullException

The connectionString is null.

ArgumentException

The connectionString is invalid or the metadata workspace is not valid.

Return to top

ObjectContext Constructor (String^, String^)

Initializes a new instance of the ObjectContext class with a given connection string and entity container name.

protected:
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", 
	Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
ObjectContext(
	String^ connectionString,
	String^ defaultContainerName
)

Parameters

connectionString
Type: System::String^

The connection string, which also provides access to the metadata information.

defaultContainerName
Type: System::String^

The name of the default entity container. When the defaultContainerName is set through this method, the property becomes read-only.

Exception Condition
ArgumentNullException

The connectionString is null.

ArgumentException

The connectionString , defaultContainerName , or metadata workspace is not valid.

Return to top
Show: