Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to scaffold Database in ASP.NET Core using Visual Studio Code

I have tried using the following command ( which works fine if I use Visual Studio) :

Scaffold-DbContext "Server=12.345.567.890;Database=ABC;Trusted_Connection=True;User Id=xyz;Password=12345;Integrated Security=false;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models -f

While trying the above command using Visual Studio code terminal, I get this error:

The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again

like image 313
Adrita Sharma Avatar asked Apr 30 '26 18:04

Adrita Sharma


1 Answers

You may have to run the command line version of scaffolding. The command you have posted is for the Package Manager in Visual Studio

dotnet ef dbcontext scaffold "Server=12.345.567.890;Database=ABC;Trusted_Connection=True;User Id=xyz;Password=12345;Integrated Security=false;" Microsoft.EntityFrameworkCore.SqlServer -o Models

Source ASP.NET Core - Write Apps with Visual Studio Code and Entity Framework

like image 118
Tubs Avatar answered May 04 '26 00:05

Tubs