C# Microsoft.Data.SqlClient-登录前握手错误

C# Microsoft.Data.SqlClient-登录前握手错误,c#,.net,sqlclient,C#,.net,Sqlclient,我正在尝试使用Microsoft.Data.SqlClient,但无法使连接正常工作。但是,当我使用System.Data.SqlClient时,一切都正常 try { using (var connection = new SC.SqlConnection(connectionString)) { connection.Open(); connection.State.ShouldBe(ConnectionState.Open); }

我正在尝试使用Microsoft.Data.SqlClient,但无法使连接正常工作。但是,当我使用System.Data.SqlClient时,一切都正常

try
{
    using (var connection = new SC.SqlConnection(connectionString))
    {
        connection.Open();

        connection.State.ShouldBe(ConnectionState.Open);
    }
}
catch (Exception e)
{
    throw;
}
连接字符串为:

"server=[[**SERVER_NAME**]];Trusted_Connection=True;database=[[**DATABASE**]];min pool size=0;max pool size=100;Application Name=Data.Tests.DotNet;timeout=120"
我得到的错误是:

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 - )
我能找到的所有内容都会在“错误:0-”之后显示一些消息

有人能帮忙吗

更新

公司的环境包括:

  • Dev/UAT-Ms Sql Server 2012企业版(基于Prem)
  • 产品-Ms Sql Server 2016 Azure(云)
  • 连接字符串:

  • 开发/用户体验:
  • 制作:

  • 将“TrustServerCertificate=true”添加到连接字符串的末尾可能会解决此问题。

    明显的问题是,为什么不能使用System.Data.SqlClient?当然,这是一个公平的问题:在我们的环境中,我们的开发和Uat是基于prem ms sql server的,但我们的产品在Azure中。我们还拥有.NET4.7.2和Core3.1应用程序。此外,我们还有一个“通用”框架dll,其中包含我们的数据库交互类。我的测试目前显示System.Data.SqlClient可以在.net 4.7.2中连接到Azure,但Core 3.1不能。System.Data.SqlClient可以在.net Core 3.1中工作。我知道这是事实。你可能有不同的问题。
    "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;"