DbContext Constructors

Definition

Overloads

DbContext()

Initializes a new instance of the DbContext class. The OnConfiguring(DbContextOptionsBuilder) method will be called to configure the database (and other options) to be used for this context.

DbContext(DbContextOptions)

Initializes a new instance of the DbContext class using the specified options. The OnConfiguring(DbContextOptionsBuilder) method will still be called to allow further configuration of the options.

DbContext()

Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs

Initializes a new instance of the DbContext class. The OnConfiguring(DbContextOptionsBuilder) method will be called to configure the database (and other options) to be used for this context.

C#
protected DbContext ();
C#
[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 ();
C#
[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 ();
Attributes

Remarks

See DbContext lifetime, configuration, and initialization for more information and examples.

Applies to

Entity Framework Core 9.0 i druge verzije
Proizvod Verzije
Entity Framework Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0

DbContext(DbContextOptions)

Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs
Source:
DbContext.cs

Initializes a new instance of the DbContext class using the specified options. The OnConfiguring(DbContextOptionsBuilder) method will still be called to allow further configuration of the options.

C#
public DbContext (Microsoft.EntityFrameworkCore.DbContextOptions options);
C#
[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);
C#
[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);

Parameters

options
DbContextOptions

The options for this context.

Attributes

Remarks

See DbContext lifetime, configuration, and initialization and Using DbContextOptions for more information and examples.

Applies to

Entity Framework Core 9.0 i druge verzije
Proizvod Verzije
Entity Framework Core 1.0, 1.1, 2.0, 2.1, 2.2, 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0