3

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 Answers1

2

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"
MorenajeRD
  • 849
  • 1
  • 11
  • 27
  • Still I'm getting this error. I tried whitelisting the IP address as well. "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: TCP Provider, error: 0 - A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.)" –  May 17 '22 at 03:44
  • 1
    @VimleshKumar that's a different issue, verify the Conection String and port. – MorenajeRD May 17 '22 at 12:45