Which method in DbContext is used to save changes to the database?

  • CommitChanges()
  • SaveChanges()
  • SubmitChanges()
  • UpdateDatabase()
In Entity Framework, the SaveChanges() method in the DbContext is used to persist changes made to entities to the underlying database. When you modify, add, or delete entities in a DbContext, you need to call SaveChanges() to ensure that these changes are reflected in the database. This method executes SQL statements necessary to synchronize the state of the entities with the database, committing the changes within a transaction if all changes succeed.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *