EntityEntry.State Property


Gets or sets that state that this entity is being tracked in.

This method sets only the state of the single entity represented by this entry. It does not change the state of other entities reachable from this one.

When setting the state, the entity will always end up in the specified state. For example, if you change the state to Deleted the entity will be marked for deletion regardless of its current state. This is different than calling Remove(TEntity) where the entity will be disconnected (rather than marked for deletion) if it is in the Added state.

public virtual Microsoft.EntityFrameworkCore.EntityState State { get; set; }
member this.State : Microsoft.EntityFrameworkCore.EntityState with get, set
Public Overridable Property State As EntityState

Property Value



See Accessing tracked entities in EF Core for more information.

Applies to