title: Are DBSet<> object's ids set when assigning one to the other?
body: <p>I have two entities with relation one-many in DB and corresponding classes generated by reverse engineering the database.</p>
  <pre><code>public partial class Assets
  {
      public int AssetsId { get; set; }
      public string Description { get; set; }
      public int? PersonId { get; set; }
  
      public virtual Persons Person { get; set; }
  }
  
  public partial class Persons
  {
      public Persons()
      {
          Assets = new HashSet&lt;Assets&gt;();
      }
  
      public int PersonId { get; set; }
      public string LastName { get; set; }
      public string FirstName { get; set; }
  
      public virtual ICollection&lt;Assets&gt; Assets { get; set; }
  }
  </code></pre>
  <p>When I assign one entity to the other do the corresponding ID's are set automatically (i am curious if they are set before SaveChanges is called, so i could use it without committing all current changes).</p>
  <pre><code>static void Main(string[] args)
  {
      Context c = new Context();
  
      var a = new Assets();
      a.AssetsId = 1;
      var p = new Persons();
      p.PersonId = 2;
  
      c.Add(a);
      c.Add(p);
  
      a.Person = p;    //does it set a.PersonId = 2
      p.Assets.Add(a); //does it set a.PersonId = 2
          
      c.SaveChanges();
  }
  </code></pre>