If you are trying to create a model for an existing database in Entity Framework Core and you are receiving the following error:
Scaffold-DbContext : 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.
The try the following steps to solve the issue:
In Visual Studio, select menu Tools -> NuGet Package Manger -> Package Manger Console and run the following command:
- Install-Package Microsoft.EntityFrameworkCore.SqlServer
- Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design
- Install-Package Microsoft.EntityFrameworkCore.Tools
After that you should be able to see the new packages in your project. Now, run again the scaffold command:
Scaffold-DbContext "Server=.;Database=MyDB;Trusted_Connection=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir Models
You will notice that the models have been created successfully.
admin this post was great. thank you so much ;) great job
ReplyDelete