04_Entity States - Maniconserve/EF-Core GitHub Wiki
Entity States in EF Core
Added
- The entity is new and not yet saved in the database.
- EF Core will generate an INSERT query when SaveChanges() is called.
Modified
- The entity exists in the database, but some properties have changed.
- EF Core will generate an UPDATE query for modified properties.
Unchanged
- The entity exists in the database and has no changes.
- EF Core does not generate any SQL commands for it.
Deleted
- The entity exists in the database but is marked for deletion.
- EF Core will generate a DELETE query when SaveChanges() is called.
Detached
- The entity is not being tracked by EF Core.
- It will not be included in database operations unless explicitly attached.