ObjectContext Constructor

 

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.


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.


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.


ObjectContext Constructor (EntityConnection, String)

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

[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", 
	Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected 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.


ObjectContext Constructor (String)

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

[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:DisposeObjectsBeforeLosingScope", 
	Justification = "Object is in fact passed to property of the class and gets Disposed properly in the Dispose() method.")]
public 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.


ObjectContext Constructor (String, String)

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

[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", 
	Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected 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.