Mid EF Core How to detach an entity from the context? Use context.Entry(entity).State = EntityState.Detached.Useful to avoid tracking or to simulate detached state.