Share via


DbContext 建構函式 (DbCompiledModel)

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

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

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

語法

'宣告
<SuppressMessageAttribute("Microsoft.Usage", "CA2214:DoNotCallOverridableMethodsInConstructors")> _
<SuppressMessageAttribute("Microsoft.Reliability", "CA2000:Dispose objects before losing scope")> _
Protected Sub New ( _
    model As DbCompiledModel _
)
'用途
Dim model As DbCompiledModel 

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

參數

請參閱

參考

DbContext 類別

DbContext 多載

System.Data.Entity 命名空間