• Uncategorized

About sql-server : dotnet-ef-scaffold-login-fails-for-user-sa-on-a-SqlServer-MacOSLinux

Question Detail

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"

Question Answer

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.

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.

You may also like...

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.