title: Why my entity primary key shows to be modified after updating entity?
body: <p>I have a class <code>ApplicationUser</code> that inherits from <code>IdentityUser</code>. I added the property <code>LastLoggedIn</code> which is <code>OffsetDateTime</code> datatype and I modify it with every request to the API. Also, I am using <a href="http://entityframework-plus.net/audit" rel="nofollow noreferrer"><code>Audit</code></a> from entityframework plus to log user add/update/delete operations and this is how I came across this issue. every time I update the <code>ApplicationUser</code> entity's <code>LastLoggedIn</code> property I can see that the <code>Id</code> property has been modified as well, showing same old and new value. Why my primary key is being modified here?</p>
  
  <p>I posting the relevant code,</p>
  
  <pre><code>public class ApplicationUser : IdentityUser {
          [Required, StringLength(50)]
          [Display (Name = "First Name")]
          public string FirstName { get; set; }
          public OffsetDateTime? LastLoggedIn { get; set; }
  }
  </code></pre>
  
  <p>Method calling the entity, since the class inherits from <code>IdentityUser</code>, I am using <code>UserManager</code></p>
  
  <pre><code> public async Task UpdateUserLastActivityDateAsync (string userId, string timeZone) {
              var user = await userManager.FindByIdAsync(userId);
              user.LastLoggedIn = timeZone.GetInstantOffsetDateTime();
              await unitOfWork.CompleteAsync(); //  = context.SaveChangesAsync();
          }
  </code></pre>
  
  <p>I tried the following but I get an exception,</p>
  
  <pre><code>builder.Entity&lt;ApplicationUser&gt;()
          .Property(e =&gt; e.Id)
          .ValueGeneratedOnAddOrUpdate()
          .Metadata.BeforeSaveBehavior = PropertySaveBehavior.Ignore;
  </code></pre>
  
  <blockquote>
    <p>The property 'Id' cannot be configured as 'ValueGeneratedOnUpdate' or
    'ValueGeneratedOnAddOrUpdate' because the key value cannot be changed
    after the entity has been added to the store.</p>
  </blockquote>