title: Entity Framework adds new record for navigation property
body: <p>I have two entities, defined as following</p>
  
  <pre><code>public class Corporation
  {
      public int Id{get;set;}
      public string Name{get;set;}
      public List&lt;Location&gt; Locations{get;set;} // All locations under this corp
  }
  
  public class Location
  {
      public int Id{get;set;}
      public Corporation Corporation{get;set;} // Corporation is required in configuraion
  }
  </code></pre>
  
  <p>When I try to add a Corporation and then a location, I get two Corporation defined. One by my function that adds Corporation(which is fine), and one by the function that adds location(which is the issue). </p>
  
  <p>Location adding function is like this:</p>
  
  <pre><code>public void AddLocation(int locationId)
  {
       using (Context context = new Context())
       {
            Location location = new Location();
            location.Corporation = GetCorporationFromDb(corpId);
  
            context.Locations.Add(location); // This one adds another same Corporation to DB
            context.SaveChanges();
       }
  }
  </code></pre>
  
  <p>How can I avoid this? I have to add Corporation before Location because in the implementation Location calculates an electronic code using Corporation's database Id.</p>