Delen via


IDbContextFactory<TContext> Interface

Definition

Caution

Use IDesignTimeDbContextFactory instead.

A factory for creating derived DbContext instances. Implement this interface to enable design-time services for context types that do not have a public default constructor. At design-time, derived DbContext instances can be created in order to enable specific design-time experiences such as Migrations. Design-time services will automatically discover implementations of this interface that are in the same assembly as the derived context.

public interface IDbContextFactory<out TContext> where TContext : DbContext
[System.Obsolete("Use IDesignTimeDbContextFactory instead.", true)]
public interface IDbContextFactory<out TContext> where TContext : DbContext
type IDbContextFactory<'Context (requires 'Context :> DbContext)> = interface
[<System.Obsolete("Use IDesignTimeDbContextFactory instead.", true)>]
type IDbContextFactory<'Context (requires 'Context :> DbContext)> = interface
Public Interface IDbContextFactory(Of Out TContext)

Type Parameters

TContext

The type of the context.

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.
Attributes

Methods

Create(DbContextFactoryOptions)

Creates a new instance of a derived context.

Applies to