IDbContextFactory<TContext> Interface

Definition

Defines a factory for creating DbContext instances.

C#
public interface IDbContextFactory<out TContext> where TContext : DbContext
C#
public interface IDbContextFactory<TContext> where TContext : DbContext

Type Parameters

TContext

The DbContext type to create.

This type parameter is covariant. That is, you can use either the type you specified or any type that is more derived. For more information about covariance and contravariance, see Covariance and Contravariance in Generics.
Derived

Remarks

See Using DbContextFactory for more information and examples.

Methods

CreateDbContext()

Creates a new DbContext instance.

CreateDbContextAsync(CancellationToken)

Creates a new DbContext instance in an async context.

Applies to

Toode Versioonid
Entity Framework Core 5.0, 6.0, 7.0, 8.0, 9.0