Trouble Scaffolding DbContext using SQL Server

628 Views Asked by At

I am trying to Scaffold-DbContext using the following command, but I'm getting error and not able to connect to remote server.

 Scaffold-DbContext "Server=766626hahskjsh.server.amz.com;port:3433;Database=testdb;User Id=user123;Password=actualPassword" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

The error is "Keyword not supported: 'port:3433;database'"

I don't know what mistake I'm doing as I'm new to C#. Please help me resolve this issue.

1

There are 1 best solutions below

2
Misael Moneró On BEST ANSWER

there is an incorrect syntax on your connection string, to specify a port we do it like this: (after the server name separated by a , )

Scaffold-DbContext "Server=766626hahskjsh.server.amz.com,3433;Database=testdb;User Id=user123;Password=actualPassword"