title: How to keep original value of a source property in Automapper mapping?
body: <p>The input view model:</p>
  
  <pre><code>public class FacilityInputModel 
  {
      public int Id { get; set; }
      public string Name { get; set; }
  }
  </code></pre>
  
  <p>The domain model:</p>
  
  <pre><code>public class FacilityInputModel 
  {
      public int Id { get; set; }
      public string Name { get; set; }
      public string OriginalName { get; set; }
  }
  </code></pre>
  
  <p>I am to allow users to change the name of a facility but still keep its original name.</p>
  
  <p>Say facility is (I am writing json just for convenience)</p>
  
  <pre><code>{id:1, name='Facility1', originalName='Facility1'}
  </code></pre>
  
  <p>when created.</p>
  
  <p>I am to change the name by posting a <code>FacilityInputModel</code>.</p>
  
  <pre><code>{id:1, name='Facility2'}
  </code></pre>
  
  <p>In C# code to update the entity:</p>
  
  <pre><code>var entity = _repository.Find(id);
  _repository.Detach(entity);
  entity = Mapper.Map&lt;Facility&gt;(model);
  
  _repository.Update(entity);
  _repository.Save();
  </code></pre>
  
  <p>The <code>entity</code> I get before <code>Mapper.Map</code> </p>
  
  <pre><code>{id:1, name='Facility1', originalName='Facility1'}
  </code></pre>
  
  <p>But after the mapping, the entity is</p>
  
  <pre><code>{id:1, name='Facility2', originalName=null}
  </code></pre>
  
  <p>instead of </p>
  
  <pre><code>{id:1, name='Facility2', originalName='Facility1'}
  </code></pre>
  
  <p>In my mapping, I tried to <code>Ignore</code> the <code>OriginalName</code></p>
  
  <pre><code>CreateMap&lt;Facility, FacilityInputModel&gt;()
      .ReverseMap()
      .ForMember(x =&gt; x.OriginalName, opt =&gt; opt.Ignore());
  </code></pre>
  
  <p>But it never worked. Also tried </p>
  
  <pre><code>    .ForMember(x =&gt; x.NameInWebAdmin, opt =&gt; opt.DoNotUseDestinationValue());
  </code></pre>
  
  <p>Still won't work.</p>
  
  <p>So the question is how to avoid existing values from being wiped away in the mapping. And get an after-mapping entity:</p>
  
  <pre><code>{id:1, name='Facility2', originalName='Facility1'}
  </code></pre>