7-second EF startup time even for tiny DbContext

后端 未结 2 1227
借酒劲吻你
借酒劲吻你 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:23

    As per several comments, the reason the second runs so fast is due to the connection manager caching the connections. Which leads me to believe that getting that initial connection is the problem.

    Things to try:

    1. Change your connection string to use the IP address of the db server instead of it's name.

    2. Connect to the database server using SQL Management Studio using the exact same credentials and mechanism. Do so from the machine that takes 7 seconds. Assuming that takes awhile, investigate to see what protocols are in use and ensure that the one you want is the first in the list.

    3. Put a network analyzer on your machine and watch what it does.

提交回复
热议问题