Search code examples
c#.netsql-serverasp.net-corealibaba-cloud-rds

Trouble Scaffolding DbContext using SQL Server


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.


Solution

  • 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"