Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

dotnet ef scaffold login fails for user sa on a SqlServer MacOS/Linux

I'm executing this command, and definitely using the correct password, but yet it keeps telling me that the login failed.

My password is using a special character ($), and I've read that I should be using quotes to make a string literal, but it does not work on MacOS/Linux.

dotnet ef dbcontext scaffold "Server=.;Database=MY_DB;Trusted_Connection=False;User ID=sa;Password=$MYPASSWORD" Microsoft.EntityFrameworkCore.SqlServer -o Models -c "DbContext"
like image 400
Elertan Avatar asked Mar 23 '18 13:03

Elertan


2 Answers

I came across this issue.

Switch out your double quotes for single quotes and you should be able to execute in terminal.

dotnet ef dbcontext scaffold 'Server=.;Database=MY_DB;Trusted_Connection=False;User ID=sa;Password=$MYPASSWORD' Microsoft.EntityFrameworkCore.SqlServer -o Models -c "DbContext"

Here is a link to special characters that need to be escaped. https://askubuntu.com/a/278695/325994

like image 126
Jason Foglia Avatar answered Oct 12 '22 01:10

Jason Foglia


In order to escape the $ on the connection string, you should be escaping the string using \ as such dotnet ef dbcontext scaffold "Server=.;Database=MY_DB;Trusted_Connection=False;User ID=sa;Password=\$MYPASSWORD" Microsoft.EntityFrameworkCore.SqlServer -o Models -c "DbContext" instead.

like image 35
Elertan Avatar answered Oct 12 '22 01:10

Elertan