<div>Contributed By: <a href="http://carloscds.net/" target="_blank">Carlos dos Santos</a></div> <div>Published on: 2013-11-03</div> <hr/> <div class="font-italic">That article was published more than three years ago. Some content such as older Visual Studio version, "incoming" features, etc. might be outdated. However, the article may still be pertinent to read.</div>
Entity Framework Improving Entity Framework load times with NGEN
Beginning with Entity Framework 6, all EF components are contained within the
EntityFramework.dll and are no longer divided between various .NET Framework components. Therefore, the EF DLL is not optimized for the JIT (Just in Time) of the computer where it is being run, just as .NET is.
We can improve this by running the Ngen.exe command, which pre-compiles the DLL and eliminates this process while loading the DLL. This way, the charging time gets shorter, and we can save a few seconds on our application load.
To do this, open a Visual Studio Studio command prompt, it is within the Visual Studio installation options, with a name similar to this: "Developer Command Prompt for VS 20xx". In my case, I'm using VS 2013, so the prompt is "Developer Command Prompt for VS2013".
Open this prompt as an administrator, go to your application directory and run the NGen command, as below:
C: My Project> ngen install EntityFramework.dll
After that you will see a screen that looks like this: