title: Update specific fields in Entity Framework
body: <p>I have a model:</p>
  <pre><code>public class VR
  {
      [Key]
      public int ID { get; set; }
      public string FullName { get; set; }
      public string CreatedBy { get; set; }
      public DateTime? Created { get; set; }
      public string ModifiedBy { get; set; }
      public DateTime? Modified { get; set; }
  }
  </code></pre>
  <p>My controller's <code>Edit</code> function:</p>
  <pre><code>    // POST: VRs/Edit/5
      [HttpPost]
      [ValidateAntiForgeryToken]
      public IActionResult Edit(VR vR)
      {
          if (ModelState.IsValid)
          {
              var Result = (from c in _context.MyVR.Where(c =&gt; c.ID == vR.ID) select c).Single();
  
              vR.Created = Result.Created;
              vR.CreatedBy = Result.CreatedBy;
              vR.ModifiedBy = User.Identity.Name;
              vR.Modified = DateTime.Now;
          
              _context.Update(vR);
              _context.SaveChanges();
              return RedirectToAction(&quot;Index&quot;);
          }
          return View(vR);
      }
  </code></pre>
  <p>and I get the error below:</p>
  <blockquote>
  <p>The instance of entity type '<code>UNTest.ViewModels.VR</code>' cannot be tracked because another instance of this type with the same key is already being tracked. For new entities consider using an <code>IIdentityGenerator</code> to generate unique key values.</p>
  </blockquote>