public void GuardarUsuario(int id, string nombre, string password, int tipo, bool activo) { try { if (id == 0) { //var tipousuario = new Cfg_AtiposUsuarios { causutipo=Convert.ToInt16(nousutipo), Nombre=Nombre}; var nuevomodulo = new Cfg_cUsuarios { cUsuNombre = nombre, cUsucontrasena = password, cUsuActivo = activo, causutipo = Convert.ToInt16(tipo) }; entidad.AddToCfg_cUsuarios(nuevomodulo); } entidad.SaveChanges(); XtraMessageBox.Show("Usuario Guardado", "Usuarios"); } catch (DbEntityValidationException ex) { // Retrieve the error messages as a list of strings. var errorMessages = ex.EntityValidationErrors .SelectMany(x => x.ValidationErrors) .Select(x => x.ErrorMessage); // Join the list to a single string. var fullErrorMessage = string.Join("; ", errorMessages); // Combine the original exception message with the new one. var exceptionMessage = string.Concat(ex.Message, " La Validación del error : ", fullErrorMessage); // Throw a new DbEntityValidationException with the improved exception message. throw new DbEntityValidationException(exceptionMessage, ex.EntityValidationErrors); } }