I have this method that receives a list of type VentasLinias
and inserts each record in the database
public void InsertLines(int idVenta , List<VentasLinias> listVentas)
{
foreach (VentasLinias vl in listVentas)
{
db.VentasLinias.Add(vl);
db.SaveChanges();
i++;
}
}
I have 2 doubts about this the first one is, does the SaveChanges()
do it for iteration or when leaving the loop?
The other doubt is that when I try to save I get this error:
An exception of type 'System.Data.Entity.Validation.DbEntityValidationException' occurred in EntityFramework.dll but was not controlled in the user's code
Additional information: Validation error for one or more entities. See the 'EntityValidationErrors' property for more details.
If I debug the exception I see this but I do not see any clue as to which field is failing me.
Thank you,