Click here to Skip to main content
15,909,822 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Here is my save changes method:

C#
public void SaveChanges()
       {
           var transaction = _dbContext.Database.BeginTransaction();       

           try
           {
               _dbContext.SaveChanges();
               transaction.Commit();
           }
           catch (DbEntityValidationException ex)
           {            
               transaction.Rollback();
               throw new DbEntityValidationException(ex.EntityValidationErrors.Last().ValidationErrors.FirstOrDefault().ErrorMessage);
           }

       }



when validation is failed then ex.EntityValidationErrors.count =1
and when validation is failed second time then it will count=2
and so on.

why its count incrementing..

sorry for my poor english..
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900