DbContext 构造函数

定义

重载

DbContext()

初始化 DbContext 类的新实例。 OnConfiguring(DbContextOptionsBuilder)将调用 方法来配置数据库 (以及) 用于此上下文的其他选项。

DbContext(DbContextOptions)

使用指定的选项初始化 类的新实例 DbContextOnConfiguring(DbContextOptionsBuilder)仍会调用 方法以允许进一步配置选项。

DbContext()

初始化 DbContext 类的新实例。 OnConfiguring(DbContextOptionsBuilder)将调用 方法来配置数据库 (以及) 用于此上下文的其他选项。

protected DbContext ();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EF Core isn't fully compatible with trimming, and running the application may generate unexpected runtime failures. Some specific coding pattern are usually required to make trimming work properly, see https://aka.ms/efcore-docs-trimming for more details.")]
protected DbContext ();
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EF Core isn't fully compatible with trimming, and running the application may generate unexpected runtime failures. Some specific coding pattern are usually required to make trimming work properly, see https://aka.ms/efcore-docs-trimming for more details.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("EF Core isn't fully compatible with NativeAOT, and running the application may generate unexpected runtime failures.")]
protected DbContext ();
Protected Sub New ()
属性

注解

有关详细信息 和示例,请参阅 DbContext 生存期、配置和初始化

适用于

DbContext(DbContextOptions)

使用指定的选项初始化 类的新实例 DbContextOnConfiguring(DbContextOptionsBuilder)仍会调用 方法以允许进一步配置选项。

public DbContext (Microsoft.EntityFrameworkCore.DbContextOptions options);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EF Core isn't fully compatible with trimming, and running the application may generate unexpected runtime failures. Some specific coding pattern are usually required to make trimming work properly, see https://aka.ms/efcore-docs-trimming for more details.")]
public DbContext (Microsoft.EntityFrameworkCore.DbContextOptions options);
[System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EF Core isn't fully compatible with trimming, and running the application may generate unexpected runtime failures. Some specific coding pattern are usually required to make trimming work properly, see https://aka.ms/efcore-docs-trimming for more details.")]
[System.Diagnostics.CodeAnalysis.RequiresDynamicCode("EF Core isn't fully compatible with NativeAOT, and running the application may generate unexpected runtime failures.")]
public DbContext (Microsoft.EntityFrameworkCore.DbContextOptions options);
new Microsoft.EntityFrameworkCore.DbContext : Microsoft.EntityFrameworkCore.DbContextOptions -> Microsoft.EntityFrameworkCore.DbContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EF Core isn't fully compatible with trimming, and running the application may generate unexpected runtime failures. Some specific coding pattern are usually required to make trimming work properly, see https://aka.ms/efcore-docs-trimming for more details.")>]
new Microsoft.EntityFrameworkCore.DbContext : Microsoft.EntityFrameworkCore.DbContextOptions -> Microsoft.EntityFrameworkCore.DbContext
[<System.Diagnostics.CodeAnalysis.RequiresUnreferencedCode("EF Core isn't fully compatible with trimming, and running the application may generate unexpected runtime failures. Some specific coding pattern are usually required to make trimming work properly, see https://aka.ms/efcore-docs-trimming for more details.")>]
[<System.Diagnostics.CodeAnalysis.RequiresDynamicCode("EF Core isn't fully compatible with NativeAOT, and running the application may generate unexpected runtime failures.")>]
new Microsoft.EntityFrameworkCore.DbContext : Microsoft.EntityFrameworkCore.DbContextOptions -> Microsoft.EntityFrameworkCore.DbContext
Public Sub New (options As DbContextOptions)

参数

options
DbContextOptions

此上下文的选项。

属性

注解

有关详细信息和示例,请参阅 DbContext 生存期、配置和初始化和使用 DbContextOptions

适用于