I'm trying to use the Microsoft.Data.SqlClient but cannot get the connection to work. However when I use the System.Data.SqlClient everything is ok.
try
{
using (var connection = new SC.SqlConnection(connectionString))
{
connection.Open();
connection.State.ShouldBe(ConnectionState.Open);
}
}
catch (Exception e)
{
throw;
}
The connection string is:
"server=[[**SERVER_NAME**]];Trusted_Connection=True;database=[[**DATABASE**]];min pool size=0;max pool size=100;Application Name=Data.Tests.DotNet;timeout=120"
The error that I am getting is:
Microsoft.Data.SqlClient.SqlException
A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: HTTP Provider, error: 0 - )
Everything that I can find show some message after the 'error: 0 -'.
Can anyone help?
UPDATE
The company's environments are:
Connection Strings:
"server=[[**SERVER_NAME**]];Trusted_Connection=True;database=[[**DATABASE**]];min pool size=0;max pool size=100;Application Name=Data.Tests.DotNet;timeout=120"
"Server=tcp:[[**SERVER_NAME]],1433;database=[[**DATABASE**]];Persist Security Info=False;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Authentication='Active Directory Integrated';Application Name=Data.Tests.DotNet;"
Adding "TrustServerCertificate=true" to the end of connection string may resolve the issue.