DbContext.DisposeAsync Method

Definition

Releases the allocated resources for this context.

public virtual System.Threading.Tasks.ValueTask DisposeAsync ();

Returns

Implements

Remarks

Entity Framework Core does not support multiple parallel operations being run on the same DbContext instance. This includes both parallel execution of async queries and any explicit concurrent use from multiple threads. Therefore, always await async calls immediately, or use separate DbContext instances for operations that execute in parallel. See Avoiding DbContext threading issues for more information and examples.

See DbContext lifetime, configuration, and initialization for more information and examples.

Applies to

Product Versions
Entity Framework Core 3.0, 3.1, 5.0, 6.0, 7.0, 8.0, 9.0