Learning EF - Error running Scaffold-DbContext

Stephen Ng Qui Sang 10 Reputation points
2023-02-07T22:47:49.0433333+00:00

I am learning how to user Entity Framework where the models are built from an existing SQL server. I ran this command in the package manager:

Scaffold-DbContext “Server=xxx; database=Contoso; user id = cnnxxxxx; password = xxxx” Microsoft.EntityFrameworkCore.SqlServer –ContextDir Data -OutputDir Models

I got the following error:

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.)

I know the database connection string works as I built a quick connection and sent the output of a table to the console.

I appreciate any ideas to fix this issue. Thanks.

Entity Framework Core
Entity Framework Core
A lightweight, extensible, open-source, and cross-platform version of the Entity Framework data access technology.
742 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Christoffer Broberg 15 Reputation points
    2023-02-15T11:23:13.4333333+00:00

    Hi,

    I had the same issue today, and setting the Encrypt=False in the connectionstring solved the problem
    Thanks a lot!

    3 people found this answer helpful.

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.