Share via


DbContext 建構函式

[此頁面專屬於 Entity Framework 第 6 版。最新版本可從 'Entity Framework' NuGet 套件取得。如需 Entity Framework 的詳細資訊,請參閱 msdn.com/data/ef。]

使用慣例建構新的內容執行個體,以建立將建立連接的資料庫名稱。 根據慣例建立的名稱為衍生內容類別的完整名稱 (命名空間 + 類別名稱)。 如需使用此方式建立連接的詳細資訊,請參閱類別註解。

命名空間:  System.Data.Entity
組件:  EntityFramework (在 EntityFramework.dll 中)

語法

'宣告
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")> _
Protected Sub New
'用途
Dim instance As New DbContext()
[SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")]
protected DbContext()
[SuppressMessageAttribute(L"Microsoft.Reliability", L"CA2000:Dispose objects before losing scope")]
[SuppressMessageAttribute(L"Microsoft.Usage", L"CA2214:DoNotCallOverridableMethodsInConstructors")]
protected:
DbContext()
[<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")>]
[<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")>]
new : unit -> DbContext
protected function DbContext()

請參閱

參考

DbContext 類別

DbContext 多載

System.Data.Entity 命名空間