Connecting a .NET project in Visual Studio for Mac to an Azure SQL Edge

Viewed 1054

Im having a hard time connecting VS for mac to an Azure SQL server through docker. Im running m1 so I've used the azure sql edge.

This is my Docker:

docker run --cap-add SYS_PTRACE -e 'ACCEPT_EULA=1' -e 'MSSQL_SA_PASSWORD=Password.1' -p 1433:1433 --name azuresqledge -d mcr.microsoft.com/azure-sql-edge

and this is my connection string:

"DefaultConnection": "data source=localhost,1433;Database=master;User Id=sa;Password=SPassword.1;"

and Im getting a

Login failed for user 'sa'

when I entered

dotnet ef database update

I tried connecting through Azure Data Studio and I was able to connect the same. Any thoughts what I am missing here?

Thanks

2 Answers

You have a problem in your connection string password:

 d=sa;Password=SPassword.1;"

you have a SPassword with S at the beginning.

I'm also giving my 2 cents here with my connection string:

"ConnectionStrings": {
    "DefaultConnection": "Data Source=localhost;Initial Catalog=DBNAME;User Id=sa;Password=SqlStrongPassword2;"
  },

For Mac: I tried the given command but docker image would not run correctly on Mac. It stopped with error.

Then I modified the command without using quotes and few other changes, the image then worked correctly.

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

Make sure you are able to see the docker container running. Check the container log.

I was able to login using DataGrip without any issue.

Related