You are asking:
We do not need a call to _context.SaveChanges () in every Delete / Update / ... operation?
No, we do not. When calling Delete we do not arbitrarily delete the object - we put it to delete.
The same thing with Update , although you do not need to do anything else that makes changes to the object. All properties (created by default template) will implement INotifyPropertyChanged so that it knows when the object was changed.
All objects (in the database at first - auto-generated by the defullt template) have the State property. This property is supported by the ObjectContext if moves occur within the scope of the ObjectEntity.
eg.
Customer c; using(var context = new MyEntityContext()) { c = context.Customer.FirstOrDefault();
Then you call SaveChanges all entites that have the state Added Deleted or Modified will have their changes in the database in the local transaction
EDIT
If the object is marked for deletion and you try to change it, you will get an InvalidOperationException
Jens kloster
source share