skip to Main Content

I am new to mac and got Azure Sql Edge running using docker image.
This is the command I ran to run the image.

docker run -d --name SQLServerImg -e ACCEPT_EULA=Y -e SA_PASSWORD=StrongPassword@123 -p 1433:1433 mcr.microsoft.com/azure-sql-edge

This is the connection string in my appsettings.json

"ConnectionStrings": {
    "EmployeesManagementDB" : "Server=127.0.0.1,1433;Database=EmployeesManagementDB;MultipleActiveResultSets=true;User Id=sa;Password=StrongPassword@123"
  }

This is my Progoram.cs

builder.Services.AddControllers();
var connectionString = builder.Configuration.GetConnectionString("EmployeesManagementDB");
builder.Services.AddDbContext<EmployeeContext>(options => options.UseSqlServer(connectionString));

when I run dotnet ef database update
I keep getting the following error.

A connection was successfully established with the server, but then an error occurred during the pre-login handshake. (provider: TCP Provider, error: 35 - An internal exception was caught)

How can I fix this issue? Am I missing anything?

Thank you.

2

Answers


  1. In your connection string it seems like the parameter "User Id" is wrong,
    instead try to replace it with "User".
    Also, Try to remove "MultipleActiveResultSets=true" from your connection string.

    Try:

    "ConnectionStrings": {
    "EmployeesManagementDB" : "Server=127.0.0.1,1433;Database=EmployeesManagementDB;User=sa;Password=StrongPassword@123"}
    
    Login or Signup to reply.
  2. You are probably missing the flag to trust server’s certificate.
    Just add "TrustServerCertificate=True;":

    "ConnectionStrings": {
        "EmployeesManagementDB" : "Server=127.0.0.1,1433;Database=EmployeesManagementDB;User=sa;Password=StrongPassword@123;TrustServerCertificate=True;"
    }
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search