title: Adding a query hint when calling Table-Valued Function
body: <p>I'm calling a Table-Valued Function from entity framework and need to be able to add the <code>option (recompile)</code> to it because the execution plan it picks up is not optimal. Running the query in SQL Server Management Studio, it would look something like this:</p>
  
  <pre><code>select 
         * 
  from dbo.fDE_myquery(0, 0, 3309, '7/1/2013', '7/1/2014', 0, 0)
  option (recompile)
  </code></pre>
  
  <p>By from EF, there's no way to add that hint, AFAIK. The EF part looks something like:</p>
  
  <pre><code>var query = from f in ctx.fDE_myQuery(aBool, anotherBool, StartDate, 
              EndDate, someInt, moreBool)
              select f;
  </code></pre>
  
  <p>I saw this question:</p>
  
  <p><a href="https://stackoverflow.com/questions/9890699/how-do-i-control-parameter-sniffing-and-or-query-hints-in-entity-framework">How do I control parameter sniffing and/or query hints in entity framework?</a></p>
  
  <p>But it's old, and the accepted solution doesn't really give enough information on how to <em>actually</em> implement the suggested solution (use plan guides) with entity framework. If that is the only solution, how do you get entity framework to use a plan guide anyway?</p>