Connecting to SQLExpress Database takes long time
Upgraded .net 4.8 C# app to .net 8. The new version takes 30 seconds to connect to SQLExpress database on server (\ServerName\SQLExpress). Original version took less than 1 second to connect to same server. Management Studio and reporting tool also take less than 1 second to connect. Built a small app in .net 6 and 8 and both take 30 seconds to connect. Once the first connection completes all of the subsequent connections are less than a second. Looking for advice as to where I can look to figure out where the delay is cominmg from. I believe I have ruled out network traffic and the server. Seems .net 6/8 first connection is taking a long time to resolve but once it does it is fine.
Here are the commands I am using:
CPLdbconnect = ("Data Source = Server\\sqlexpress; " +
"Initial Catalog = CPL; " +
"Persist Security Info = True; " +
"User ID = userid; " +
"Password = password; " +
"TrustServerCertificate = True; " +
"Connect Timeout = 60; ");
.net 6 - using System.Data.SqlClient.SqlConnection con = new(CPLdbconnect);
.net 8 - using Microsoft.Data.SqlClient.SqlConnection con = new(CPLdbconnect);
con.Open();