Is there any breaking change in regard to TrustServerCertificate property of System.Data.SqlClient for .NET 5?
I have recently an issue at work after upgrading an ASP.NET Core 3.1 application to .NET 5. It worked correctly on all environments (e.g. PreProd, Prod) when targeting 3.1, but failed on Prod only after upgrade to .NET 5.
The error was login related:
A connection was successfully established with the server, but then an error occurred during the login process.The target principal name is incorrect
And the solution was the one indicated by this answer, namely setting
TrustServerCertificate=true in the connection string.
This was required because the PreProd SQL Server did not require encryption, while the Production one did.
However, I still do not understand why this happened.