title: C# repository pattern SQL query with Entity Framework 6 exception data reader is incompatible with specified entity
body: <p>I tried to execute a custom SQL query. However I get the following error when I execute my method.</p>
  <blockquote>
  <p>Source: Entity Framework</p>
  <p>Message: The data reader is incompatible with the specified 'SomeProject.Data.Entities.Config'. A member of the type, 'Id', does not have a corresponding column in the data reader with the same name.</p>
  </blockquote>
  <p>This is my method:</p>
  <pre><code>private readonly IRepositoryAsync&lt;Config&gt; _configRepository;
  
  private IEnumerable&lt;Config&gt; getConfig()
  {
      var sqlCommand = &quot;select * from tbl_Config&quot;;
  
      return this._configRepository.SelectQuery(sqlCommand);
  }
  </code></pre>
  <p>This is my entity class:</p>
  <pre><code>public class Config : Entity
  {
      public int Id { get; set; }
  
      public string Key { get; set; }
      public string Value { get; set; }
      public string ValueType { get; set; }
      public string Description { get; set; }
  }
  </code></pre>
  <p>This is my <code>IRepositoryAsync</code>:</p>
  <pre><code>public interface IRepositoryAsync&lt;TEntity&gt; : IRepository&lt;TEntity&gt; where TEntity : class, ITrackable
  {
      Task&lt;TEntity&gt; FindAsync(params object[] keyValues);
      Task&lt;TEntity&gt; FindAsync(CancellationToken cancellationToken, params object[] keyValues);
      Task&lt;bool&gt; DeleteAsync(params object[] keyValues);
      Task&lt;bool&gt; DeleteAsync(CancellationToken cancellationToken, params object[] keyValues);
      Task&lt;int&gt; ExecuteCustomSQL(string sqlCommand, params object[] parameters);
  } 
  </code></pre>
  <p>This is my .SqlQuery method within the repository:</p>
  <pre><code>public virtual IQueryable&lt;TEntity&gt; SelectQuery(string query, params object[] parameters)
  {
      return this.Set.SqlQuery(query, parameters).AsQueryable();
  }
  </code></pre>
  <p>Here is the mapping:</p>
  <pre><code>// Table &amp; Column Mappings
  this.ToTable(&quot;db.TBL_CONFIG&quot;);
  this.Property(t =&gt; t.Id).HasColumnName(&quot;PK_CONF&quot;);
  this.Property(t =&gt; t.Key).HasColumnName(&quot;KEY&quot;);
  this.Property(t =&gt; t.Value).HasColumnName(&quot;VALUE&quot;);
  this.Property(t =&gt; t.ValueType).HasColumnName(&quot;VALUETYPE&quot;);
  this.Property(t =&gt; t.Description).HasColumnName(&quot;DESCRIPTION&quot;);
  </code></pre>
  <p>The SQL command I have chosen is a simple one since I wanted to test the <code>.SqlQuery</code> method first. It says that it can't find the the column name for &quot;Id&quot; although I checked the mapping and it is definitely there.</p>
  <p>Did I miss something else?</p>