ObjectContext-Konstruktor (EntityConnection, String)
[Diese Seite bezieht sich auf Entity Framework Version 6. Die neueste Version ist als 'Entity Framework' NuGet-Paket verfügbar. Weitere Informationen zu Entity Framework finden Sie unter msdn.com/data/ef.]
Initialisiert eine neue Instanz der ObjectContext-Klasse mit einer angegebenen Verbindung und einem angegebenen Entitätencontainernamen.
Namespace: System.Data.Entity.Core.Objects
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
<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 Sub New ( _
connection As EntityConnection, _
defaultContainerName As String _
)
'Usage
Dim connection As EntityConnection
Dim defaultContainerName As String
Dim instance As New ObjectContext(connection, _
defaultContainerName)
[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
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA2214:DoNotCallOverridableMethodsInConstructors", Justification = L"Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")]
protected:
ObjectContext(
EntityConnection^ connection,
String^ defaultContainerName
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors", Justification = "Class is internal and methods are made virtual for testing purposes only. They cannot be overrided by user.")>]
new :
connection:EntityConnection *
defaultContainerName:string -> ObjectContext
protected function ObjectContext(
connection : EntityConnection,
defaultContainerName : String
)
Parameter
- connection
Typ: System.Data.Entity.Core.EntityClient.EntityConnection
Ein EntityConnection, das Verweise auf das Modell und die Datenquellenverbindung enthält.
- defaultContainerName
Typ: System.String
Der Name des standardmäßigen Entitätencontainers. Wenn der defaultContainerName mit dieser Methode festgelegt wird, ist die Eigenschaft schreibgeschützt.
Ausnahmen
Ausnahme | Bedingung |
---|---|
ArgumentNullException | connection ist NULL. |
ArgumentException | connection, defaultContainerName oder Metadaten-Arbeitsbereich ist ungültig. |