The term "scaffold-dbcontext" is not recognized as the name of a cmdlet, function, script file, or operating program

When trying to sketch using the asp.net kernel, this command

scaffold-dbcontext "Data source = (local); Start Directory = MyDb; Integrated Security = True;" Microsoft.EntityFrameworkCore.sqlserver -outputdir Models

Gives this error.

scaffold-dbcontext: the term "scaffold-dbcontext" is not recognized as the name of a cmdlet, function, script file, or executable program. Check the spelling of the name or indicate the path to it. that the path is correct and try again. On line: 1 char: 1 + scaffold-dbcontext "Data source = (local); Start directory = MyDB; B ... + ~~~~~~~~~~~~~~~~~~ CategoryInfo: ObjectNotFound: (scaffold-dbcontext: String) [], CommandNotFoundException + FullyQualifiedErrorId: CommandNotFoundException

I tried the solution here , but this does not work for me.

Any idea what could be the cause / cure?

+19
source share
5 answers

-, ,

 Install-Package Microsoft.EntityFrameworkCore.Tools 

, :

  • (, Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.SqlServer.Design...) .

  • PM ( , ...)

, : dbcontext, , :

Microsoft.EntityFrameworkCore.SqlServer. , .

, VS ( , ).

+35
  • , project.json "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final".

enter image description here

enter image description here

+12

: NuGet .

NuGet .

Devanathan , , NuGet .

0

.NetCore 2.2, Git Bash. , , .

, C:\App\ProjectName:

 dotnet ef dbcontext scaffold "Server=.\;Database=Databasename;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o Model
0

... Microsoft, .

:

:

Scaffold - DbContext "Server=(localdb)\mssqllocaldb;Database=myDbName;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer - OutputDir Models

:

Scaffold-DbContext "Server=(localdb)\mssqllocaldb;Database=myDbName;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models

, , Visual Studio.

https://docs.microsoft.com/en-us/ef/core/get-started/aspnetcore/existing-db

0

Source: https://habr.com/ru/post/1654362/


All Articles