7-second EF startup time even for tiny DbContext

后端 未结 2 1234
借酒劲吻你
借酒劲吻你 2021-02-14 04:50

I am trying to reduce the startup time of my EF-based application, but I find that I cannot reduce the amount of time taken for an initial read below 7 seconds even for a single

2条回答
  •  佛祖请我去吃肉
    2021-02-14 05:26

    After taking the code your wrote putting it in its own project I found that the project's platform target had a great effect on the start up time of the EF framework.

    When targeting an x64 platform, I received results similar to yours (7 second spin up on the first DbContext and <1 second on the second). When targeting x86 the spin up time for the first DbContext gets reduced by about 4 seconds down to 3.34633 seconds while the second DbContext takes a similar amount of time as in the x64 case.

    I am not sure why this happens but it must have to do with how the Entity Framework initializes itself in different environments. I have posted a separate question about that here.

提交回复
热议问题