title: AutoMapper with EF Core - unchanged entity marked as changed and deleted
body: <p>I have a strange problem with the combination of EF Core 2.0 and AutoMapper 8.1.0.</p>
  
  <p>As it would be very nontrivial to extract some meaningful snippet of actual code, I will describe the structure, that is simple enough:</p>
  
  <p>I have a database entity model (POCO only) mapped to DB via EF Core Code First - defined using the fluent API. Above that there is a domain model. Between these two layers there is AutoMapper configuration. When there is a need to map updated domain object to a simple entity one, it utilizes the overload</p>
  
  <pre><code> Mapper.Map(DomainObjectInstance, EntityObjectInstance, DomainType, EntityType);
  </code></pre>
  
  <p>to update the actual EntityObjectInstance tracked by EF Core.</p>
  
  <p>It used to work pretty well. Unfortunately, there were some refactorings in the model and after that it stopped working together with the EF Core. After updating one of the domain object, it is being deleted from the database.</p>
  
  <p>What I found out - after calling the <code>Map</code> method, the <code>ChangeTracker</code> in <code>DBContext</code> detects a change in one of the important foreign keys - this is an entity that is also contained in a collection of another entity (typical 1-M relation). However, if I inspect the property, there is <code>IsChanged = true</code>, but the actual <code>CurrentValue</code> and <code>OriginalValue</code> are the same.</p>
  
  <p>Also interesting is that the <code>CurrentValue == OriginalValue</code> returns <code>false</code> but <code>CurrentValue.Equals(OriginalValue)</code> returns <code>true</code> because of un/boxing.</p>
  
  <p>This change and its detection is definitely caused during the <code>Map</code> method. If I comment it out, the pipeline works fine. Although there is no any actual change in the data and I set the mapping for this property to be ignored, the change in EF Core is still detected. If I do a "manual mapping" and assign values from domain object to entity object myself, the issue disappears. But there are quite some fields and I want to benefit from autoMapper usage.</p>