title: Compiled query replacement for .Net 4.0 and EF6
body: <p>I have an <code>Asp.Net MVC</code> application built with <code>.Net 4.0</code> and <code>EF6</code>. To improve performance of the application, I came across various posts and got to know that we must have <strong>compiled queries</strong> to drastically increase the performance of the application.</p>
  
  <p>So I went on searching for <code>compiled query</code> and wrote my own as below:</p>
  
  <pre><code>public static Func&lt;KEEntities, IQueryable&lt;tblProperty&gt;&gt; GetProperties =
              CompiledQuery.Compile((KEEntities db) =&gt; 
              from property in db.tblProperties select property);
  </code></pre>
  
  <p>But that query above gives me an error saying Error <strong>There is no implicit reference conversion from 'KEApplication.Models.EntityModel.KEEntities' to 'System.Data.Entity.Core.Objects.ObjectContext'.</strong> </p>
  
  <p>Again after going through few posts and especially <strong><a href="https://stackoverflow.com/questions/6426508/how-do-i-precompile-an-entity-framework-code-first-query/6731102#6731102"><code>This</code></a></strong>, by reading the <strong><a href="https://stackoverflow.com/a/6731102/2065039"><code>answer</code></a></strong> there, I was disappointed to know that the <code>compiled queries</code> wasn't supported in <code>.Net 4</code> and <code>EF6</code>. I also read that <code>EF</code> version > 4 provided automatic compilation of queries, but in my case I am not seeing any improvements, if it happened to. Are there any other possible ways to achieve functionality like <code>compiled query</code> for the above configurations?</p>