Share via


ObjectContext Constructors

Definition

Overloads

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(String)

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

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, String)

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

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.

public ObjectContext (System.Data.Entity.Core.EntityClient.EntityConnection connection);
new System.Data.Entity.Core.Objects.ObjectContext : System.Data.Entity.Core.EntityClient.EntityConnection -> System.Data.Entity.Core.Objects.ObjectContext
Public Sub New (connection As EntityConnection)

Parameters

connection
EntityConnection

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

Exceptions

The connection is null.

The connection is invalid or the metadata workspace is invalid.

Applies to

ObjectContext(String)

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

[System.Diagnostics.CodeAnalysis.SuppressMessage("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);
new System.Data.Entity.Core.Objects.ObjectContext : string -> System.Data.Entity.Core.Objects.ObjectContext
Public Sub New (connectionString As String)

Parameters

connectionString
String

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

Attributes

Exceptions

The connectionString is null.

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

Applies to

ObjectContext(EntityConnection, Boolean)

Creates an ObjectContext with the given connection and metadata workspace.

public ObjectContext (System.Data.Entity.Core.EntityClient.EntityConnection connection, bool contextOwnsConnection);
new System.Data.Entity.Core.Objects.ObjectContext : System.Data.Entity.Core.EntityClient.EntityConnection * bool -> System.Data.Entity.Core.Objects.ObjectContext
Public Sub New (connection As EntityConnection, contextOwnsConnection As Boolean)

Parameters

connection
EntityConnection

connection to the store

contextOwnsConnection
Boolean

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

Applies to

ObjectContext(EntityConnection, String)

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

[System.Diagnostics.CodeAnalysis.SuppressMessage("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 (System.Data.Entity.Core.EntityClient.EntityConnection connection, string defaultContainerName);
new System.Data.Entity.Core.Objects.ObjectContext : System.Data.Entity.Core.EntityClient.EntityConnection * string -> System.Data.Entity.Core.Objects.ObjectContext
Protected Sub New (connection As EntityConnection, defaultContainerName As String)

Parameters

connection
EntityConnection

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

defaultContainerName
String

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

Attributes

Exceptions

The connection is null.

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

Applies to

ObjectContext(String, String)

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

[System.Diagnostics.CodeAnalysis.SuppressMessage("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);
new System.Data.Entity.Core.Objects.ObjectContext : string * string -> System.Data.Entity.Core.Objects.ObjectContext
Protected Sub New (connectionString As String, defaultContainerName As String)

Parameters

connectionString
String

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

defaultContainerName
String

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

Attributes

Exceptions

The connectionString is null.

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

Applies to