DbContext コンストラクター (String, 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")> _
Public Sub New ( _
    nameOrConnectionString As String, _
    model As DbCompiledModel _
)
'使用
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
)

パラメーター

  • nameOrConnectionString
    型 : System.String
    データベース名または接続文字列。

参照

参照

DbContext クラス

DbContext オーバーロード

System.Data.Entity 名前空間