IDbContextFactory<TContext> 介面

定義

定義用於建立 DbContext 實例的處理站。

public interface IDbContextFactory<out TContext> where TContext : DbContext
public interface IDbContextFactory<TContext> where TContext : DbContext
type IDbContextFactory<'Context (requires 'Context :> DbContext)> = interface
Public Interface IDbContextFactory(Of Out TContext)
Public Interface IDbContextFactory(Of TContext)

類型參數

TContext

DbContext 建立的類型。

這是共變數的型別參數。 也就是說,您可以使用您指定的類型,或衍生程度較高的任何類型。 如需共變數與反變數的詳細資訊,請參閱泛型中的共變數與反變數
衍生

備註

如需詳細資訊和範例,請參閱 使用 DbCoNtextFactory

方法

CreateDbContext()

建立新的 DbContext 執行個體。

CreateDbContextAsync(CancellationToken)

在非同步內容中建立新的 DbContext 實例。

適用於