ObjectContext Constructor
Initializes a new instance of the ObjectContext class.
Assembly: EntityFramework (in EntityFramework.dll)
| Name | Description | |
|---|---|---|
![]() | ObjectContext(EntityConnection^) | Initializes a new instance of the ObjectContext class with the given connection. During construction, the metadata workspace is extracted from the EntityConnection object. |
![]() | ObjectContext(EntityConnection^, Boolean) | Creates an ObjectContext with the given connection and metadata workspace. |
![]() | ObjectContext(EntityConnection^, String^) | Initializes a new instance of the ObjectContext class with a given connection and entity container name. |
![]() | ObjectContext(String^) | Initializes a new instance of the ObjectContext class with the given connection string and default entity container name. |
![]() | ObjectContext(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.
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.
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.
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. |
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. |
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. |

