title: Updating Nested Objects in Entity Framework
body: <p>recently I discover that EF doesn't update nested object.
  For few days I try to figure out how to do this but unfortunately I'm stuck with this problem.</p>
  
  <p>I have Object</p>
  
  <pre><code>public class ProjectEntity : AuditableEntity&lt;int&gt;
  {
  
      public string CustumerCompany { get; set; }
      public string CustomerRepresentative { get; set; }
  
      public string ProjectTitle { get; set; }
      public string WwsNumber { get; set; }
  
      [ForeignKey("ParentProjectId")]
      public virtual ProjectEntity ParentProject { get; set; }
  
      public int? ParentProjectId { get; set; }
  
      public virtual ICollection&lt;ProjectServicesEntity&gt; Service { get; set; }
  }
  </code></pre>
  
  <p>Then Service object</p>
  
  <pre><code>public class ProjectServicesEntity : AuditableEntity&lt;int&gt;
  {
      /// &lt;summary&gt;
      /// Service Number
      /// &lt;/summary&gt;
      public int Number { get; set; }
      /// &lt;summary&gt;
      /// Service Name
      /// &lt;/summary&gt;
      public string Name { get; set; }
  
      /// &lt;summary&gt;
      /// Positions
      /// &lt;/summary&gt;
      public virtual ICollection&lt;ProjectPositionsEntity&gt; Positions { get; set; }
  
      [ForeignKey("ProjectId")]
      public virtual ProjectEntity Project { get; set; }
  
      public int ProjectId { get; set; }
  }
  </code></pre>
  
  <p>and Positions object:</p>
  
  <pre><code>public class ProjectPositionsEntity : AuditableEntity&lt;int&gt;
  {
      /// &lt;summary&gt;
      /// Position number
      /// &lt;/summary&gt;
      public int Number { get; set; }
  
      /// &lt;summary&gt;
      /// Position Name
      /// &lt;/summary&gt;
      public string Name { get; set; }
  
      /// &lt;summary&gt;
      /// Organization Unit for position
      /// &lt;/summary&gt;
      public virtual ICollection&lt;ProjectsOutsourcedPositionEntity&gt; OrganizationUnit { get; set; }
      /// &lt;summary&gt;
      /// Represents if position is outsourced
      /// &lt;/summary&gt;
      public bool OutSource { get; set; }
      /// &lt;summary&gt;
      /// Comments for position
      /// &lt;/summary&gt;
      public string Remarks { get; set; }
  
      [ForeignKey("ServiceId")]
      public virtual ProjectServicesEntity Service { get; set; }
  
      public int ServiceId { get; set; }
  
  }}
  </code></pre>
  
  <p>And my update method:</p>
  
  <pre><code>public void Update(T entity)
      {
  
              DbContext.Entry(entity).State = EntityState.Modified;
              DbContext.SaveChanges();
  }
  </code></pre>
  
  <p>When have page were all data is represented and when I try to edit some data in Service's or in Position's it doesn't update.
  Anybody had this kind of problem ? </p>
  
  <p>Every example that I saw it was only with nested object that has 1 level deep but as you can see my object has 2 level nest.</p>