.net-8.0.net-4.8sqlclientblazor-hybrid

Connection string for connecting to SQL Server using SqlClient in Blazor hybrid on .NET 8


I have a question. I need use a special user account on SQL Server. This account has a user id and password. When I connect using an app on .NET 4.8, I don't have a problem, but when I try to connect using an app on .NET 8 (Blazor hybrid), I have a problem with the connection.

This is my connection string:

"ConnectionStrings": "Server=ServerAddress;Database=DatabaseName;User Id=User;password=Password;"

What do I need to add to my connection string? Why it is different between .NET 4.8 and .NET 8?

Thank you

I try connect to a SQL Server database from a .NET 8 Blazor hybrid app. Solution for .NET 4.8 is ok, but it didn't work on .NET 8.


Solution

  • Finale i found working solution. I added TrustServerCertificate=True; to connection string. It works on .Net8 (Blazor hybrid). Example:"ConnectionStrings": "Server=ServerAddress;Database=DatabaseName;User Id=User;password=Password; TrustServerCertificate=True;" But i don't have answer on the question: why it is work on .NET 4.8 whiteout TrustServerCertificate=True;