EF6 Precompilation

Is there a way to precompile an EF request so that the application does not need to compile it (even if it is being executed for the first time)?

I have many complex queries that take some time to complete when using L2E. For example, for one request that I tested in the Sql Server profiler reports, it takes about 300 ms, but actually this request completes after about 4.5 seconds on my PC (Xeon Quad Core 2.6 GHz with 8 GB of RAM. This means that my computer waits for the data to arrive for approximately 0.5 s and takes about 4 seconds to compile and execute the request and finally read the data on my computers (these are just 4 records). This is a lot of time, especially since ToListAsyns () will not return UI control until the actual request is sent to the database data, so that means that all 4 seconds my application “freezes.” One way is to use Task.Run () instead of ToListAsync,but this will allow my application to show some wait sign, there will still be a delay of 4 s.

On some older PCs, this may mean that the user will wait 10 seconds to compile the requests, which is not desirable. So, does anyone know how I can precompile all my queries so that even the first time they run without delay?

+4
source share

Source: https://habr.com/ru/post/1584497/


All Articles