Hello
When I first call using entity framework like
context.Employee.FirstOrDefault() it will take about 50 to 60 seconds and from second call it will take only 2 to 3 seconds
how do i reduce this.? I already created precomplied view but it did not work
can anyone help in this?
Loading
Jignesh TrivediPosted Feb 12, 2015, 6:14 AM
To do this you have to implement Application Initialization on IIS
Please refer
http://blogs.msdn.com/b/amol/archive/2013/01/25/application-initialization-ui-for-iis-7-5.aspx
http://www.orcsweb.com/blog/terri/implementing-application-initialization-on-iis-7-5/
hope this will help you.
Jignesh TrivediPosted Feb 12, 2015, 7:06 AM
hope this will help you.
keyurPosted Feb 12, 2015, 7:02 AM
Thansk for this,but i already made Custom factory for intialization and it works.
Can we check context is intialized or not ?
keyurPosted Feb 12, 2015, 5:51 AM
Yes you are right. I major all factors like when I call service method to reach method it take about 10 seconds and then when i call EF query to get only one data it takes about 40 seconds
so I just want to reduce EF calling time. and yes i tried to use Global.asax file but it will not called anytime.So I made custom host factory and write code there for intialiazation but then problem in that when my service idel it will not call again hostfactory.
I think Global.asax is good idea but its not called any idea why ?
thanks for the quick response
Jignesh TrivediPosted Feb 12, 2015, 5:46 AM
Hi,
I think In your case
First Call time = first connection time to web service+ initilization of EF + generating SQL Query + SQL server prepair statics for your query + Execution time of query :)
yes you can write warm up process (it is nothing but simple method which call your web service method) which is run at application start event of Global.asax.....
so whenever your iis is reset application start event of Global.asax call first and it will make initialization process....
hope this will help you.
keyurPosted Feb 12, 2015, 5:37 AM
thanks for the answer.
I am using EF 5.0. I have generated precompiled view but it will not helpful.
Basically I have webservice and when my first call take place using EF it will take about 1 minute and after each call taking 2 to 3 seconds.so i have to reduce first call. or if that not possible then have to do some mechnisam to intialize context before service initalized
I do not have much idea in EF
Can you please help this ?
Jignesh TrivediPosted Feb 12, 2015, 5:32 AM
Hi,
First time execution include time to generate native code for EF base dll and generate equvallent SQL.
When you execute Linq to entity query first time Entity framework base dll is generate the native code and you can improve the start up performace by using NGen.exe
Please refer my article:
http://www.c-sharpcorner.com/UploadFile/ff2f08/entity-framework-6-0-ngen-exe-and-startup-performance/
By the way which Entity Framework version you are working with?
hope this will help you.