IDbContextFactory<TContext>.CreateDbContextAsync Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
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
If the CancellationToken is canceled.
Remarks
The caller is responsible for disposing the context; it will not be disposed by any dependency injection container.
Applies to
Collaborate with us on GitHub
The source for this content can be found on GitHub, where you can also create and review issues and pull requests. For more information, see our contributor guide.
Entity Framework