public async Task <bool> UpdateAsync(TEntity entity) { if (entity == null) { throw new ArgumentNullException($"{nameof(AddAsync)} entity must not be null"); } try { _context.Entry(entity).State = EntityState.Modified; await _context.SaveChangesAsync(); return(true); } catch (Exception ex) { throw new Exception($"{nameof(entity)} could not be updated: {ex.Message}"); } }
public void UpdateBirthdayOnly(Person person) { _efDemoContext.Persons.Attach(person); _efDemoContext.Entry(person).Property(p => p.DateOfBirth).IsModified = true; }