public void Update(T entity) { if (CustomReflection.PropertyExists(entity, "UpdatedAt")) { PropertyInfo prop = entity.GetType().GetProperty("UpdatedAt", BindingFlags.Public | BindingFlags.Instance); if (null != prop && prop.CanWrite) { prop.SetValue(entity, DateTime.Now, null); } } _context.Entry <T>(entity).State = EntityState.Modified; }