Created
June 1, 2015 10:34
-
-
Save roboter/0671ee1c4f7be7560864 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
try | |
{ | |
// Your code... | |
// Could also be before try if you know the exception occurs in SaveChanges | |
context.SaveChanges(); | |
} | |
catch (DbEntityValidationException e) | |
{ | |
foreach (var eve in e.EntityValidationErrors) | |
{ | |
Console.WriteLine("Entity of type \"{0}\" in state \"{1}\" has the following validation errors:", | |
eve.Entry.Entity.GetType().Name, eve.Entry.State); | |
foreach (var ve in eve.ValidationErrors) | |
{ | |
Console.WriteLine("- Property: \"{0}\", Error: \"{1}\"", | |
ve.PropertyName, ve.ErrorMessage); | |
} | |
} | |
t |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment