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

后端 未结 10 505
深忆病人
深忆病人 2020-12-13 22:50

When trying to scaffold with asp.net core this command

scaffold-dbcontext \"Data Source=(local);Initial Catalog=MyDb;Integrated Security=True;\" M

10条回答
  •  误落风尘
    2020-12-13 23:40

    Scaffold command is part of dbcontext command in EF. Below are the details for successful scaffold:

    Package references required:

    
    
    
    
    

    So our scaffold command should look like:

    dotnet ef dbcontext scaffold "Server=localhost\SQLEXPRESS;Database=MyDatabase;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -o OutputDirectory
    

    Your Server value might differ as per your Db server name. Replace MyDatabase with your Database name like master and OutputDirectory to the location you want your newly created scaffolded classes like Models folder.

提交回复
热议问题