DbContext-Konstruktor (String, DbCompiledModel)
[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.]
Erstellt mit der angegebenen Zeichenfolge als Name oder Verbindungszeichenfolge für die Datenbank, mit der eine Verbindung hergestellt wird, eine neue Kontextinstanz und initialisiert sie anhand des angegebenen Modells. Siehe Klassenhinweise zur Erstellung einer Verbindung.
Namespace: System.Data.Entity
Assembly: EntityFramework (in EntityFramework.dll)
Syntax
'Declaration
<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")> _
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
Public Sub New ( _
nameOrConnectionString As String, _
model As DbCompiledModel _
)
'Usage
Dim nameOrConnectionString As String
Dim model As DbCompiledModel
Dim instance As New DbContext(nameOrConnectionString, _
model)
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
public DbContext(
string nameOrConnectionString,
DbCompiledModel model
)
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA2214:DoNotCallOverridableMethodsInConstructors")]
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:Dispose objects before losing scope")]
public:
DbContext(
String^ nameOrConnectionString,
DbCompiledModel^ model
)
[<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")>]
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")>]
new :
nameOrConnectionString:string *
model:DbCompiledModel -> DbContext
public function DbContext(
nameOrConnectionString : String,
model : DbCompiledModel
)
Parameter
- nameOrConnectionString
Typ: System.String
Entweder der Datenbankname oder eine Verbindungszeichenfolge.
- model
Typ: System.Data.Entity.Infrastructure.DbCompiledModel
Das Modell, das diesen Kontext unterstützt.