0
The following error occurs when I try to insert data into the system: Validation failed for one or more entities. See 'Entityvalidationerrors' Property for more Details. It turns out that the mistake happens when it arrives on the following line: db.SaveChanges();
, not to mention that he doesn’t even recognize this line: await db.SaveChangesAsync();
Follows code:
private async void metroTile5_Click(object sender, EventArgs e)
{
using (frm_AddUsuario addUsuario = new frm_AddUsuario(new cad_usuario()))
{
if (addUsuario.ShowDialog() == DialogResult.OK)
{
try
{
cadusuarioBindingSource.Add(addUsuario.cadUsuarioUsuarioInfo);
db.cad_usuario.Add(addUsuario.cadUsuarioUsuarioInfo);
// await db.SaveChangesAsync();
db.SaveChanges();
}
catch(Exception ex)
{
MessageBox.Show(ex.Message, "Mensagem", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}
}
}
Does anyone have any idea how I can solve this problem? Thank you!
Could update the question with the message inside Entityvalidationerrors?
– Ayrton Giffoni