EF+MVC's website will be slow when it first opens, and it will be slow to restart the application pool if it is idle for a while.
program updates, the application pool restarts, and after recycling, the program files need to be reloaded.
1, install application initialization
This is IIS8 's built-in feature, and for IIS7.5, Microsoft provides an extension package to support this feature.
Application initialization Module for IIS 7.5
Http://www.iis.net/downloads/microsoft/application-initialization
This extension does not provide the interface, need to operate the interface, you need to download the third-party plugin Applicationinitializationinstaller
Configure the application pool for StartMode to alwaysrunning
Configure the site to open preload and Doappinitafterrestart
2. NGen to generate the local image of EF
EF is no longer defaulted from version 6 with the. Net framework installation, and when the program starts, EF compiles the MSIL by Just-in-time compiler to the cost code, which is stored in memory.
Use the cmd command prompt to enter the directory where the project DLL is located, typically bin, running NGen
32bit
%windir%\microsoft.net\framework\v4.0.30319\ngen Install EntityFramework.SqlServer.dll
64bit
%windir%\microsoft.net\framework64\v4.0.30319\ngen Install EntityFramework.SqlServer.dll
3. Disable _migrationhistory
When Code first accesses EF, it accesses _migrationhistory and checks to see if the database matches the entity class to ensure that EF works correctly.
Application_Start the code Database. Setinitializer<myContext> (null) to disable this feature.
Entity Framework Startup optimization