title: Why is mapping an object PK breaking ExpressMapper?
body: <p>Trying to implement a generic repository based on <a href="https://cpratt.co/generic-entity-base-class/" rel="nofollow noreferrer">an article by Chris Pratt</a> that uses <code>object</code> as the <code>Id</code> (PK). </p>
  
  <p>All is good, until I tried to <code>.Map()</code>one of these objects with <a href="http://www.expressmapper.org/" rel="nofollow noreferrer">ExpressMapper</a>.  </p>
  
  <p>More code below.  But essentially, when I try and do this: </p>
  
  <pre><code>var dataModel = postedModel.Map(new ExampleDataModel());
  </code></pre>
  
  <p>It gives me:</p>
  
  <blockquote>
    <p>No parameterless constructor defined for this object.</p>
  </blockquote>
  
  <p>When I change the <code>Id</code> property of <code>ExampleDataModel</code> to a <code>string</code> or <code>int</code> it works fine. </p>
  
  <p>I've googled around. I don't see anything obvious, but I am a bit out of my depth. I'd like to know: </p>
  
  <ul>
  <li><p>What is causing this?</p></li>
  <li><p>Can I work round it somehow?  </p></li>
  </ul>
  
  <p>I'd like to continue using the object PK and ExpressMapper if possible because they're both suiting my project just fine.</p>
  
  <hr>
  
  <pre><code>public interface IDataModel
  {
      object Id { get; }  
  }
  
  public interface IDataModel&lt;PKT&gt; : IDataModel
  {
      new PKT Id { get; set; }
  }
  
  public abstract class DataModel&lt;PKT&gt; : IDataModel&lt;PKT&gt;
  {
      public PKT Id { get; set; }
      object IDataModel.Id
      {
          get { return this.Id; }
      }
  }
  
  
  
  public class ExampleDataModel : 
      DataModel&lt;string&gt;, 
      IDataModel&lt;string&gt;
  {
       public virtual string SomeProperty{ get; set; }
  
      // etc.
  }
  </code></pre>