title: Entity Framework takes about 30 seconds on first query
body: <p>I'm using Entity Framework 6 on a SQL Server database to query an existing database (database first, so there's an EDMX in my project).</p>
  
  <p>I've noticed that the first time I request an entity, it can take up to thirty seconds for the query to be executed. Subsequent queries to the same object then get completed in a matter of milliseconds. The actual SQL being executed is very fast so it's not a slow query.</p>
  
  <p>I've found that Entity Framework generates views on the background and that this is the most likely culprit. What I haven't found, however, is a good solution for this. There's a NuGet package that can handle the View Generation (EFInteractiveViews), but it hasn't been updated since 2014 and I hardly seem to find any information on how to use it.</p>
  
  <p>What options do I have nowadays? I've tried initializing Entity Framework on Application_Start by doing a few queries, but this doesn't seem to help much at all, and also it's quite difficult to perform the real queries on <code>Application_Start</code>, because most queries use data from the current user (who is not yet logged on at <code>Application_Start</code>) so it's difficult to run these in advance.</p>
  
  <p>I've thought about creating an ashx file that constantly polls the application by calling the API and keep it alive. I've also set the Application Pool to "AlwaysRunning" so that EF doesn't restart when the app pool is recycled. </p>
  
  <p>Does anyone have any tips or ideas on how I can resolve this or things I can try?</p>
  
  <p>Thanks a lot in advance. I've spent the better part of two days already searching for a viable solution.</p>