Donate

Entity Framework Core Scaffold-DbContext Error - The certificate chain was issued by an authority that is not trusted.

Hello,

I was converting a .NET core 2.2 console application into a .NET 7 project that will reverse engineer a sample database from Microsoft called ContosoRetailDW as the data source for my Entity Framework Core project. Upon running the Scaffold-DbContext command in Nuget Package Manager Console, an error occured was shown on the window with the specific 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.)"
Scaffold-DbContext "Server=Your_Server;Database=ContosoRetailDW;Integrated Security=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Entity Framework Core Scaffold-DbContext Error - The certificate chain was issued by an authority that is not trusted.
After reading through the forums, the solution that worked form me was to add a TrustServerCertifcate setting with a value to true or Encrypt setting set to false. The latter is the recommended one based from the forum answers.
Option 1
Scaffold-DbContext "Server=Your_Server;Database=ContosoRetailDW;Integrated Security=True;TrustServerCertificate=True" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
Option 2 - Recommended
Scaffold-DbContext "Server=Your_Server;Database=ContosoRetailDW;Integrated Security=True;Encrypt=False" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models


Cheers!

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.