EntityEntry.ReloadAsync(CancellationToken) Method

Definition

Reloads the entity from the database overwriting any property values with values from the database.

public virtual System.Threading.Tasks.Task ReloadAsync (System.Threading.CancellationToken cancellationToken = default);
abstract member ReloadAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
override this.ReloadAsync : System.Threading.CancellationToken -> System.Threading.Tasks.Task
Public Overridable Function ReloadAsync (Optional cancellationToken As CancellationToken = Nothing) As Task

Parameters

cancellationToken
CancellationToken

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

Returns

A task that represents the asynchronous operation.

Exceptions

Remarks

The entity will be in the Unchanged state after calling this method, unless the entity does not exist in the database, in which case the entity will be Detached. Finally, calling Reload on an Added entity that does not exist in the database is a no-op. Note, however, that an Added entity may not yet have had its permanent key value created.

See Accessing tracked entities in EF Core for more information and examples.

Applies to