I'm using EF in my application and it is throwing an exception
System.Data.Entity.Validation.DbEntityValidationException: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details. at System.Data.Entity.Internal.InternalContext.SaveChanges() at Capture.Controllers.HomeController.AddFirstVisit(Int32 companyId)
I can see what I need to do to learn about the error - I need to see EntityValidationErrors
but the problem is I can't debug - the code needs to be run the server so running locally does not reproduce this error.
The problem I have is, without seeing the object, how to do I get the execption out as a string?
At the moment my I use catch(Exception e)
and pass e.ToString()
to my logging engine.
How do I pass the error detail? I'm hoping something like
catch(Exception e)
{
e.innerException.EntityValidationErrors; // what should this be
}
This almost had the answer EF Code First: How do I see 'EntityValidationErrors' property from the nuget package console? but I don't get the option of e.EntityValidationErrors