title: Entity Framework Code First 30+ seconds StartUp Time
body: <p>I am aware that this has been asked too many times, but I couldn't figure out a solution from the asked questions. </p>
  
  <p>I am fairly new to Entity Framework, and I developed a small CMS panel for my websites using Entity Framework 6 and Code First approach. My problem is, the website is really slow when first running  (this is the website I am currently testing www.oakwoodpawnshop.ca) , it takes over 30 secs to load.
   After the first load, it takes about a sec to load other pages.   I am getting 89/100 from PageSpeed insights,all my images /js /css files are minimized, and done some other front-end  optimizations so I know that my problem is with EF. I have another website I've built about 3 years ago only using LINQ, no database optimization or html/image optimization, and it opens in about 3 seconds.</p>
  
  <p>I have pre generated views using Entity Framework Power Tools, and I don't have any Include method in my codes. I filtered my queries before .toList() function.I probably have a problem with my codes or database optimization, but I am unable to come up with a solution through my research, because this area is new for me.</p>
  
  <p>I've found an article in my native language asking someone with the same problem to run some codes on command prompt to see if the problem is with network settings. </p>
  
  <p>These were the lines for command prompt:</p>
  
  <p>1 - netsh int ip reset a.txt </p>
  
  <p>2 - netsh winsock reset </p>
  
  <p>3 - netsh winhttp reset proxy </p>
  
  <p>4 - netsh advfirewall reset </p>
  
  <p>5 - ipconfig /flushdns </p>
  
  <p>6 - Restart your computer and check again.</p>
  
  <p>When I did these and checked back to website, the whole website opened in 3 seconds. After a while, it started to have 30+ seconds start up time again. Obviously I can't run these commands on everyone's computer, but I am lost and I have no idea why its taking so long to start.</p>
  
  <p>Here is an example of the method I am using:</p>
  
  <pre><code>public List&lt;Categories&gt; GetCategories()
      {
          List&lt;Categories&gt; c = db.Categories.Where(x =&gt; x.TopCategoryId == 0).OrderBy(x =&gt; x.CatOrder).ToList();
  
          return c;
      }
  </code></pre>
  
  <p>I created custom methods to fetch my datas(so I can use them more easily), under a 'Worker' class to gather all my methods in one class. Could that be the problem?</p>
  
  <p>I'd be happy to provide any more information you need, and I am dealing this for about a month now with no  luck, so I am hopelessly looking for an answer, or I will have to re-create whole application without EF, because there is no way a customer would wait for a website that has a +30 sec opening time.</p>
  
  <p>Thank you in advance for all your advices!</p>