Freigeben über


DbContext-Konstruktor (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.]

Erstellt eine neue Kontextinstanz mit der angegebenen Zeichenfolge als Name oder Verbindungszeichenfolge für die Datenbank, mit der eine Verbindung hergestellt wird. Siehe Klassenhinweise zur Erstellung einer Verbindung.

Namespace:  System.Data.Entity
Assembly:  EntityFramework (in EntityFramework.dll)

Syntax

'Declaration
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")> _
Public Sub New ( _
    nameOrConnectionString As String _
)
'Usage
Dim nameOrConnectionString As String 

Dim instance As New DbContext(nameOrConnectionString)
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
public DbContext(
    string nameOrConnectionString
)
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA2214:DoNotCallOverridableMethodsInConstructors")]
public:
DbContext(
    String^ nameOrConnectionString
)
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")>]
[<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")>]
new : 
        nameOrConnectionString:string -> DbContext
public function DbContext(
    nameOrConnectionString : String
)

Parameter

  • nameOrConnectionString
    Typ: System.String
    Entweder der Datenbankname oder eine Verbindungszeichenfolge.

Siehe auch

Verweis

DbContext Klasse

DbContext-Überladung

System.Data.Entity-Namespace