public virtual string Add(TEntity entityToAdd) { string messErreur = null; try { context.Entry(entityToAdd).State = EntityState.Added; context.SaveChanges(); } catch (System.Data.Entity.Validation.DbEntityValidationException dbEx) { Exception raise = dbEx; foreach (var validationErrors in dbEx.EntityValidationErrors) { foreach (var validationError in validationErrors.ValidationErrors) { messErreur = messErreur != null ? " , " + validationErrors.Entry.Entity.ToString() : validationErrors.Entry.Entity.ToString(); } } } return(messErreur); }
public void Save() { context.SaveChanges(); }