I'm working on an MVC 5 application that uses Entity Framework 6.1.3. I'm trying to optimize the first call, which usually takes 1-4 seconds, by pre-generating the views. I understand why this is happening, but I feel like I'm missing an important step somewhere.
My current test runs the same function five times to pulls a collection of objects from my DB using EF. When I run this with 'Embed in Output Directory' set in my edmx I get the following results:
**
- First EF Call: 2617 milliseconds
- Second EF Call: 19 milliseconds
- Third EF Call: 19 milliseconds
- Fourth EF Call: 17 milliseconds
- Fifth EF Call: 20 milliseconds
**
I expect this since EF is generating the local views to access the database...
When I switch to 'Copy to Output Directory', double check that my files are being copied to the bin folder and my connection string has been updated, and then run the same test I get similar results:
**
- First EF Call: 2546 milliseconds
- Second EF Call: 19 milliseconds
- Third EF Call: 18 milliseconds
- Fourth EF Call: 18 milliseconds
- Fifth EF Call: 21 milliseconds
**
No change in the first call, which is strange. I added EF Power Tools, right-clicked on my edmx => Entity Framework => Generate Views. A 'Model1.View.cs' file was created with string for each of my tables/views, so I felt like I was on the right path. When I ran the test again I got the same results. Putting a breakpoint in each method of the newly generated 'Model1.View.cs' file shows that it's never being hit.
Am I missing an important step here? How do I tell EF to use the file that was created by EF Power Tools, or how do I make the Copy to Output Directory work as I've read online?