Entity Framework – Why explicitly set entity state to modified?

In your scenario you indeed don’t have to set the state. It is purpose of change tracking to find that you have changed a value on attached entity and put it to modified state. Setting state manually is important in case of detached entities (entities loaded without change tracking or created outside of the current context).

Leave a Comment