title: Mapping Raw SQL Results to Object List in .NET Core
body: <p>I'm transitioning from .NET Framework to Core and, while it's been a mostly seamless and beneficial process, there are some difficulties.</p>
  
  <p>The latest is how to perform the fairly simple EF-based task of taking results from a raw query and mapping those results into a list of objects of a given type. In Framework, I could so something like:</p>
  
  <pre><code>using (DbContext Context = new DbContext(Connection))
  {
      return Context.Database.SqlQuery&lt;T&gt;(Sql).ToList&lt;T&gt;();
  }
  </code></pre>
  
  <p>Where <code>Connection</code> would be a raw connection string, <code>Sql</code> a raw query string, and <code>T</code> any given type known to fit the output of the Sql.</p>
  
  <p>In Core, I can't seem to grab a new Context with nothing but a connection string, and nor can I apply the <code>SqlQuery</code> method. There's got to be as quick &amp; easy a way to do this in Core, but I can't seem to find it.</p>
  
  <p>I do have <code>System.Data.Common</code> and <code>System.Data.SqlClient</code>, along with <code>EntityFrameworkCore</code> installed into the project.</p>