Using
Try { } catch (Exception e) { throw; }
Unable to catch the detailed exception prompt, the content of E.message is "Validation failed for one or more entities. See ' entityvalidationerrors ' for more details. "
If you need to get detailed exception hints, use the
1 Try2 {3 return Base. SaveChanges ();4 }5 Catch(Dbentityvalidationexception ex)6 {7 varErrormessages =Ex. Entityvalidationerrors8. SelectMany (x =x.validationerrors)9. Select (x =x.errormessage);Ten One varFullerrormessage =string. Join ("; ", errormessages); A - varExceptionmessage =string. Concat (ex. Message,"The validation errors is:", fullerrormessage); - the Throw Newdbentityvalidationexception (Exceptionmessage, ex. entityvalidationerrors); -}
Links: Http://stackoverflow.com/questions/15820505/dbentityvalidationexception-how-can-i-easily-tell-what-caused-the-error
Catching detailed exception hints for Entity Framework 6