Probably your SQL Server does not support TLS 1.2. Please see the following Microsoft document:
There was change in Microsoft.Data.SqlClient 4.0 as described below:
"The default value of the Encrypt connection setting has been changed from false to true."
Hello,
1 - Check the type of authentication configured on the SQL Server.
2 - See the example below of a complete connection string, and adapt it to your data:
"ConnectionStrings": {
"DefaultConnection": "Server=MyServerNameOrHostIP,PortNumber;Initial Catalog=Mydatabse;User Id=YourUser;Password=YourPassword;Persist Security Info=False;Trusted_Connection=False;Encrypt=False;TrustServerCertificate=True;"
If it works or you need clarification, leave a comment.