Exception Handling with Entity Framework context.SaveChanges()

Vandana

We are making multiple updates to our Entity Framework object context based on the changes made to the UI. For e.g.

If we have an Employee entity in our context we are coding in the following manner

using (TestDBEntities testDBContext = newTestDBEntities())

{

// Code to add a new employee

// Code to update an existing employee

// Code to delete an employee

// Save changes to the database

testDBContext.SaveChanges();

}

In this scenario we want to trap all the possible exceptions that can result in during the various add, update, delete operations. Presently we have observed that SaveChanges() throws only one exception at a time like OptimisticConcurreny exception / UpdateException and aborts the transaction. Is there any in-built mechanism in EF where in we can get all possible exceptions generated during SaveChanges so that all errors can be displayed to the user at the same time and then abort the transaction?

Progress, Telerik, and certain product names used herein are trademarks or registered trademarks of Progress Software Corporation and/or one of its subsidiaries or affiliates in the U.S. and/or other countries. See Trademarks or appropriate markings.