I am using Visual Studio 2022 - v17.9.6.
When I try to modify or add either a typed dataset or an Entity Framework (v6) model from an existing SQL Server database, I get an error regarding a trusted certificate which most likely comes from Microsoft.Data.SqlClient.
I am not using that driver at all for data access. Also, I can connect to the database fine in the same application. In other words, say I have a typed dataset that works fine when debugging, it only gives me an error when I attempt to modify the typed dataset or add a new tableadapter.
In both cases, these are .NET Framework 4.8 projects.
The typed dataset error when I try to change the CommandText
for a query:
a connection was 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.)
Adding Entity Framework to a new project throws a similar error after choosing the data connection in the wizard, but it makes a reference to Microsoft.Data.SqlClient
:
Somehow, I do not have this problem when altering an already existing Entity Framework model. I only get that error when adding a new one.
Where is the reference to the Microsoft.Data.SqlClient
coming from if there aren't any references to it?
I have tried repairing my install as well as updating Visual Studio. I would like to avoid uninstalling and reinstalling if possible.
I have also tried uninstalling extensions. The only one that could be an issue looks like SQL Server Data Tools - SQL Editor. That does not seem to stay uninstalled nor does it seem likely to be at issue.
I tried adding trustServerCertificate=true
and Encrypt=False
to the connection string, but that didn't and shouldn't make a difference because the program still connects to the database fine. I only have an issue when I try to make the above changes.
I did find something about a possibly related bug in Visual Studio, but I cannot find it now and it was supposed to have been fixed in an earlier version anyhow.
Although I attempted to type in trustServerCertificate=true
into the app.config for the connection string, it ignored it.
I updated to Visual Studio v17.10.1, but that alone did not resolve the issue.
I went to Properties->Settings for the project. I clicked on the ellipsis for that connection string. The Test Connection button for the connection string gave me the same error. Selecting the Trust Server Certificate checkbox fixed the issue and testing the connection succeeded.
It looks like it was a problem with particular projects as new ones I created in .NET Framework 4.8 did not have this issue.