title: DbContext.Add changes an entity's property value
body: <p>When I invoke the method <code>DbContext.Add</code>, a property value of my entity is changing and I don't know why:</p>
  <p>I have this code (<code>context</code> is a field injected, derived from class <code>DbContext</code>):</p>
  <pre><code>    public async Task Add([FromBody] City item) {
          context.Add(item);
          await context.SaveChangesAsync();
      }
  </code></pre>
  <p>This is the <code>City</code> class:</p>
  <pre><code>public class City {
      [Required]
      [Key]
      public int Id { get; set; }
  
      [Required]
      public string Text { get; set; }
  
      [Required]
      public int StateId { get; set; }
      public virtual State State { get; set; }
  }
  </code></pre>
  <p>This is the <code>State</code> class:</p>
  <pre><code>public class State {
      [Required]
      [Key]
      public int Id { get; set; }
  
      [Required]
      public string Text { get; set; }
  }
  </code></pre>
  <p>Before <code>context.Add(item)</code> runs, the values of entity item is <code>Text = &quot;New York&quot;</code> and <code>StateId = 1</code>. But when I step execute it, <code>StateId</code> is assigned to <code>0</code>. I have no idea why is this happening. Could you help me?</p>