try
{
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);
}
}
throw;
}
---AND---
Quote:
Error: Validation failed for one or more entities. See 'EntityValidationErrors' property for more details.
public partial class ContactDetail
{
[StringLength(10)]
public string OfficeEmail { get; set; }
}
solution: correct your Data Model according to your database SET fieldNames or length.
public partial class ContactDetail
{
[StringLength(50)]
public string OfficeEmail { get; set; }
}