0

Were using Entity Framework 6.1.3 on a modular ASP.Net application. When an entity like a 'sales order' is created, this imply the initialization of several modules DbContexts. Typically the first 'sale order' created after a server reboot, takes tens of seconds to complete, and many times this results in a client side time-out, which is awful in terms of user experience.

Is this inevitable due to EF nature, or is something that can be mitigated?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459

1 Answers1

0

This "first request slowness" issue is typical EF behavior. There are several things you can do to remedy the issue, but nothing to completely make it go away. The initial creation of the contexts takes time due to the initial creation of the metadata that is used by EF. Here is an article that shows several things you can do to improve this startup time.

Also, another thing we have done in the past is force the initial creation to happen when our service endpoint app starts...this way the hit is taken by the service app, but is not seen by your end users. You can also do something similar by executing some type of script that pings your service endpoint (if using SOA) after deploying so that the first request is hit by something that isn't a true consumer.

https://www.fusonic.net/developers/2014/07/09/3-steps-for-fast-entity-framework-6-1-code-first-startup-performance/

user1011627
  • 1,741
  • 1
  • 17
  • 25