Skip to content

Instantly share code, notes, and snippets.

@Coaden
Created March 9, 2016 14:03
Show Gist options
  • Save Coaden/3858782394210973da8e to your computer and use it in GitHub Desktop.
Save Coaden/3858782394210973da8e to your computer and use it in GitHub Desktop.
dbContext SaveChanges() with Trace Output
try
{
dbModel.SaveChanges();
}
catch (DbEntityValidationException dbEx)
{
foreach (var validationErrors in dbEx.EntityValidationErrors)
{
foreach (var validationError in validationErrors.ValidationErrors)
{
Trace.TraceInformation("Property: {0} Error: {1}", validationError.PropertyName, validationError.ErrorMessage);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment