sql-serverazurevisual-studioazure-deploymentasp.net-core-scaffolding

Scaffolding a database in SSMS within Visual Studio to deploy on Azure


I have created a database in Azure and connected it in SSMS, but when I try to scaffold it in Visual Studio I always get the same error which says:

login failed for 'user'.

Any tips on how I can successfully scaffold it?.

I tried disconnecting and reconnecting it again, and I also changed my login details and I still get the same error.


Solution

  • When I tried to reproduce your requirement in my environment, I got the same error login failed for user "username".

    enter image description here

    enter image description here

    Steps to fix the issue:

    enter image description here

    enter image description here

    enter image description here

    enter image description here

    Finally, Run the below given Scaffolding command in Package Manager console in Visual Studio.

    Scaffold-DbContext "Server=tcp:<yourservername>.database.windows.net,1433;Initial Catalog=<your_database_name>;Persist Security Info=False;User ID=<User_name>;Password=<your_newly_created_password>;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
    

    enter image description here

    Model classes has been generated as shown below:

    enter image description here