title: Entity Framework - Attaching Entities - Attach Navigation Properties?
body: <p>I have the following generic code to update a disconnected entity:</p>
  
  <pre><code>public T UpdateItem(T entity)
  {
      this._dbSet.Attach(entity);
      this._dbContext.Entry(entity).State = System.Data.EntityState.Modified;
  
      this._dbContext.SaveChanges();
  
      return entity;
  }
  </code></pre>
  
  <p>If my entity contains navigation properties, those do not get attached and set to modified. Is there a way I can change this generic method to attach and set to modified, all navigation properties as well?</p>