using Entity Framework 4.0, it seems that the first time an operation is done (read or write) against an entity framework object context it takes orders of magnatude longer than the second time. For example a query the first time may take 10 seconds (yes seconds) and the second time .1 seconds.
I'm guessing that the first time the objectcontext is constructed it has to build some sort of behind the scene data structures? Is it parsing the EDMX file (I thought would have been done at compile time?)
It is building views that get cached on subsequent calls.
You can pre-generate views to avoid the first time performance hit:
http://www.dotnetspark.com/kb/3706-optimizing-performance.aspx
EF has start-up expense of loading the Entity Data Model (EDM) metadata into memory, pre-compiling views and other one-time operations, you could try using warm-up query in order to get past that.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With