Hi,
I found that this happens when I refer Microsoft.Data.SqlClient package. If I replace with System.Data.SqlClient package, above error occurs no more
System.Data.SqlClient is the ADO.NET old provider used by .NET Framework. The Microsoft.Data.SqlClient package was released in 2019 and it is the new package which supports both .NET Core and .NET Framework. You should prefer using the new package, which support new features in SQL Server.
https://devblogs.microsoft.com/dotnet/introducing-the-new-microsoftdatasqlclient/
Please check the following document for Possible reasons and solutions for this error:
1) Can anyone let me know why this error is raised when I refer Microsoft.Data.SqlClient?
Probably the TLS 1.2 is not enabled. You might need to update the server to the last version.
Use the following document to determine whether your current version of SQL Server already has support for TLS 1.2
If you still do not succeed, then please execute: SELECT @@VERSION
and provide the exact information of the version.