Hi,
I have an editable datagrid with a binding source to, to allow user to modify and add rows.
Code:
oCom.DB.Contractors.Load();
oCom.DB.Staffs.Load();
oCom.DB.Jobs.Load();
GrdMain_Employees.DataSource = staffBindingSource;
staffBindingSource.DataSource = oCom.DB.Staffs.Local.ToBindingList();
contractorBindingSource.DataSource = oCom.DB.Contractors.Local.ToBindingList();
jobBindingSource.DataSource = oCom.DB.Jobs.Local.ToBindingList();
on DB.SaveChanges() i receive the following error
Validation failed for one or more entity, see entity validation error for more details which shows the following
{System.Data.Entity.Validation.DbEntityValidationResult} with no further details
i wrapped the save call with the following, to generate a text file with error details, however it was empty
Code:
try
{
// Your code...
// Could also be before try if you know the exception occurs in SaveChanges
DB.SaveChanges();
}
catch (DbEntityValidationException e)
{
System.IO.StreamWriter SW = new System.IO.StreamWriter(@"c:\temp\er.txt", false);
foreach (var eve in e.EntityValidationErrors)
{
SW.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)
{
SW.WriteLine("- Property: \"{0}\", Error: \"{1}\"",
ve.PropertyName, ve.ErrorMessage);
}
}
throw;
}
Any suggestions, what i might be doing wrong
Thanks