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 error happens when it arrives at the following line: db.SaveChanges();
, not to mention that it does not even recognize this line: await db.SaveChangesAsync();
Here is the 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 an idea how I can solve this problem? Thank you!