What’s the difference between .SaveChanges() and .AcceptAllChanges()?

Technology CommunityCategory: Entity FrameworkWhat’s the difference between .SaveChanges() and .AcceptAllChanges()?
VietMX Staff asked 3 years ago

When working with the Entity Framework, the submission of changes to the database is automatically handled within a transaction when you call the SaveChanges method on the ObjectContext object. Also, the AcceptAllChanges method is automatically called if no exception is thrown when updating, which will reset the state of all objects to Unchanged. The AcceptAllChanges method is useful in the scenario where a transaction has failed and a user wants to retry.