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

后端 未结 10 508
深忆病人
深忆病人 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:26

    For me... when copy pasting the command from the microsoft docs, for some reason extra spacing was added around the hyphens.

    Removing the hyphens fixed it:

    wrong:

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

    good:

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

    The docs also say if you receive this error, try restarting Visual Studio.

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

提交回复
热议问题