title: Mapping a class to a stored procedure resultset "Value cannot be null.Parameter name: entityType"
body: <p>I am using <code>Entity Framework 7 RC1 Code First</code>.</p>
  
  <p>I have the following code</p>
  
  <pre><code>var resultset = await _db.Employees.FromSql&lt;Employee&gt;("dbo.sp_GetEmployees @DeptId="+ deptId).ToListAsync();
  </code></pre>
  
  <p>this works and fetches the data correctly.</p>
  
  <p>however I need to change the stored proc to contain other properties than employees are returning.</p>
  
  <p>So I adjust the stored proc and create a custom class <code>EmployeeQuery</code> that inherits from Employee with the additional properties.</p>
  
  <p>However  FromSql is a method on the <code>DbSet</code> of my <code>DBContext</code></p>
  
  <pre><code> public DbSet&lt;Employee&gt; Employees{ get; set; }
  </code></pre>
  
  <p>so I can do the same for <code>EmployeeQuery</code> by creating </p>
  
  <pre><code> public DbSet&lt;EmployeeQuery&gt; EmployeeQueryItems{ get; set; }
  </code></pre>
  
  <p>and 
        var resultset = await _db.EmployeeQueryItems.FromSql("dbo.sp_GetEmployees @DeptId="+ deptId).ToListAsync();</p>
  
  <p>however creating a <code>DBSet</code> property this tells Entity Framework to create the table in the database and it's simply just a query object. So I don't want to do the above.</p>
  
  <p>However apparently you can use the <code>DbContext</code> Set Method  as mentioned in <a href="https://github.com/aspnet/EntityFramework/issues/1864" rel="nofollow noreferrer">github</a> and in this <a href="https://stackoverflow.com/questions/28599404/how-to-run-stored-procedures-in-entity-framework-7">answer</a></p>
  
  <p>so I change my code to
           var resultset= await _db.Set().FromSql("dbo.sp_GetEmployees @DeptId="+ deptId).ToListAsync();</p>
  
  <p>However this gives me a runtime error</p>
  
  <blockquote>
    <p>ex = {"Value cannot be null.\r\nParameter name: entityType"}</p>
  </blockquote>
  
  <p>How do I get around this?</p>
  
  <p>From this <a href="https://github.com/aspnet/EntityFramework/issues/4227" rel="nofollow noreferrer">gitbub issue</a> it doesn't seem possible without creating a dummy table. </p>
  
  <p>Is there not a way to tell EF to not create the table? Like a <code>NotMapped</code> attribute on the <code>DbSet</code>?</p>