title: EF6 Query Plan Caching
body: <p>Query Plan Caching</p>
  
  <blockquote>
    <p>The first time a query is executed, it goes through the internal plan
    compiler to translate the conceptual query into the store command
    (e.g. the T-SQL which is executed when run against SQL Server). If
    query plan caching is enabled, the next time the query is executed the
    store command is retrieved directly from the query plan cache for
    execution, bypassing the plan compiler.</p>
    
    <p>The query plan cache is shared across ObjectContext instances within
    the same AppDomain. You don't need to hold onto an ObjectContext
    instance to benefit from query plan caching.</p>
  </blockquote>
  
  <p>I am using EF6 and have a TPT mapping table and the first time I try to access data from it takes 8 to 10 Sec.  But consecutive call after that just takes milliseconds. My understanding is EF store query execution plan.</p>
  
  <p>1)  It takes 5 Sec when the execution plan is not cached in EF.
  2)  And it takes less than 10 milliseconds when the execution plan is cached.</p>
  
  <p>My question is there any way to manually add execution plan to EF.</p>
  
  <p>I have seen ways to generate a pre-compile view (using generating Mapping Views with the EF Power Tools), so I was wondering if there is a way to add known execution plan to EF when it application start up.</p>