sabato 2 settembre 2023

The certificate chain was issued by an authority that is not trusted Error Number:-2146893019 A connection was successfully established with the server, but then an error occurred during the login process.

 


Quando si creano applicazioni che fanno uso di Entity Framework Core nel creare le classi che mappano una tabella esistente, può capitare che durante l'esecuzione del comando  si verifichi l'errore "Error Number:-2146893019 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.)".

Una delle possibili soluzioni è quella di inserire nella stringa di connessione, il parametro "TrustServerCertificate=True;" in modo di evitare le connessioni che non richiedono certificati.

Di seguito la stringa di connessione con il parametro indicato da utilizzare nella console "Nuget" per la creazione delle classi prendono spunto dalle tabelle del database.

PM=>Scaffold-DbContext "Server=NomeDBSqlServer;Database=NomeDatabase;TrustServerCertificate=True;Trusted_Connection=True;" 



Nessun commento: