Startup/first query extremely slow

c# entity-framework entity-framework-core

Question

It takes a while (3 minutes+) to 'create/compile' my DbContext. The web server starts in about 5 seconds, but when I do the first query to my database, EF 2.0 has to 'build/create/compile' the database in memory or something, I think? The next requests are almost instant. This was a Database First creation of the DbContext, the database already exists in MSSQL and has data. The DbContext contains about 500 DbSet's with relations.

Is there a way to speed this up by doing the 'creation(mapping?)' of my Entity Framework's DbContext before running the web server (at developmenttime), create the file/mappings it needs, so the first request is fast too?

1
3
10/11/2017 11:38:59 PM

Popular Answer

In general this is normal Entity framework behavior by default, but from other side of cause there are some ways to resolve this course of things.

For example you can try:

  • disable database initialization
  • using pre-generation views
  • "warm" loading

Please try to read this articles:

0
12/28/2017 10:22:25 PM


Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow