title: Exception in use Automapper: The instance of entity type cannot be tracked because another instance with the key is already being tracked
body: <p>I use ASP.NET Core with EFCore 2.0.3 and Automapper 6.2.2</p>
  
  <p>Here is my model:</p>
  
  <pre><code>    public class StudentClass
      {
          public int Id { get; set; }
          public int ClassId { get; set; }
          public Class Class { get; set; }
          public int ProfId { get; set; }
          public Professor Prof { get; set; }
          public string Description { get; set; }
          public DateTimeOffset LastUpdateTime { get; set; }
          public DateTimeOffset CreateTime { get; set; }
      }
  </code></pre>
  
  <p>And My Entity</p>
  
  <pre><code>    public class StudentClassEntity
      {
          public int Id { get; set; }
  
          public int ClassId { get; set; }
          [ForeignKey("ClassId")]
          public virtual Class Class { get; set; }
          public int ProfId { get; set; }
          [ForeignKey("ProfId")]
          public Professor Prof { get; set; }
          public string Description { get; set; }
          public DateTimeOffset LastUpdateTime { get; set; }
          public DateTimeOffset CreateTime { get; set; }
          public virtual List&lt;Task&gt; Tasks { get; set; }
      }
  </code></pre>
  
  <p>And I tried to update <code>StudentClass</code> So here is my sample method:</p>
  
  <pre><code>        public void Update()
          {
  
              var studentclass = new StudentClass();
              studentclass.Id = 7;
              studentclass.CreateTime = System.DateTimeOffset.MinValue;
              studentclass.Description = $"new desc - {System.DateTime.Now.Millisecond}";
              studentclass.ProfId = 5;
              studentclass.ClassId = 7;
  
  
              var entity = _context.StudentClasses.FirstOrDefault(x =&gt; x.Id == studentclass.Id);
  
              if (entity != null)
              {
                  entity = _mapper.Map&lt;StudentClassEntity&gt;(studentclass);
                  _context.StudentClasses.Update(entity);
                  _context.SaveChanges();
              }
          }
  </code></pre>
  
  <p>And my Automapper map:</p>
  
  <pre><code> CreateMap&lt;StudentClass, StudentClassEntity&gt;()
   .ForMember(m =&gt; m.Description, o =&gt; o.MapFrom(x =&gt; x.Description))
   .ForMember(m =&gt; m.LastUpdateTime, o =&gt; o.MapFrom(f =&gt; DateTimeOffset.Now))
   .ForAllOtherMembers(m =&gt; m.UseDestinationValue());
  </code></pre>
  
  <p>So I got the exception:</p>
  
  <pre><code>The instance of entity type cannot be tracked because another instance with the key value "Id:7" is already being tracked.
  </code></pre>
  
  <p>But if instead of using Automapper I just map manually:</p>
  
  <pre><code>if (entity != null)
  {
       //entity = _mapper.Map&lt;StudentClassEntity&gt;(studentclass);
      entity.Description = studentclass.Description;
      entity.LastUpdateTime = DateTimeOffset.Now;
  
      _context.StudentClasses.Update(entity);
      _context.SaveChanges();
  }
  </code></pre>
  
  <p>It would be updated DB without exception. Where is the problem? Did I missed anythings? How create Map in Automapper to update entity without exception?</p>