IDbContextFactory<TContext>.CreateDbContextAsync Method

Definition

Creates a new DbContext instance in an async context.

public virtual System.Threading.Tasks.Task<TContext> CreateDbContextAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member CreateDbContextAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
override this.CreateDbContextAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task<'Context (requires 'Context :> Microsoft.EntityFrameworkCore.DbContext)>
Public Overridable Function CreateDbContextAsync (Optional cancellationToken As CancellationToken = Nothing) As Task(Of TContext)

Parameters

cancellationToken
CancellationToken

A CancellationToken to observe while waiting for the task to complete.

Returns

Task<TContext>

A task containing the created context that represents the asynchronous operation.

Exceptions

Remarks

The caller is responsible for disposing the context; it will not be disposed by any dependency injection container.

Applies to