0

I have a problem with connection string password to connect to database in visual studio.

In the end of password has a simple quote. I tried to escape using ' and others way like password="****'", password='****'', password='****'', password="****'". I'm using Pomelo.EntityFrameworkCore.MySql. Can some one help me?

I tried this in visual studio PM console :

PM> Scaffold-DbContext "server=remoteServe, port=3306; User Id=Myuser; database=database; Password=1234'" Pomelo.EntityFrameworkCore.MySql -OutputDir Models -ContextDir Context

return this erro:

Format of the initialization string does not conform to specification starting at index 108
niltongc
  • 9
  • 2
  • Paste the actual command you are using (replace server, user and password with fake ones) and specify, what kind of shell (cmd, powershell, bash, etc.) you are using. – lauxjpn Jan 08 '23 at 22:20
  • What is the actual error text you are getting? BTW, you have typo in 'passsword' word itself. Also please check https://stackoverflow.com/a/36479541/822455 – Mike Mozhaev Jan 08 '23 at 22:28
  • Please provide enough code so others can better understand or reproduce the problem. – Community Jan 09 '23 at 11:06

1 Answers1

0

Assuming your password is 1234', the following command will work:

Scaffold-DbContext "server=127.0.0.1;user=test;password='1234''';database=test" [...]

Use a pair of single quotes around the password value and escape all single quotes of the password value with a second single quote.

lauxjpn
  • 4,749
  • 1
  • 20
  • 40