After upgrading to Microsoft.Data.SqlClient 4, I immediatelly started to get connection failures.
Let’s have a look at the exact error message:
A connection was successfully established with the server, but then an error occurred during the login process. (provider: SSL Provider, error: 0 - The certificate chain was issued by an authority that is not trusted.)
The reason of this error is that with the release of version 4.0, a breaking change was introduced to improve security:
The default value of the `Encrypt` connection option changed from `false` to `true`. With the increased emphasis on secure-by-default, the growing use of cloud databases, and the need to ensure connections are secure, Microsoft decided it was time for this backwards-compatibility-breaking change.
You can of course get back to the previous situation by explicitly setting the ‘encrypt’ option to ‘false’.
"server=exampleserver;database=ExampleDB;integrated security=True;Encrypt=False"
But a better solution is to enable encrypted connections to the database.