Search code examples
entity-frameworkvisual-studiopowershell-cmdlet

The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet


I have a solution with two project, one is the main project and the second a project that will use EF Core 10.0 RC2.

In the second project I use this three commands to install EF Core and run this nuget commands to install it:

Install-Package Microsoft.EntityFrameworkCore.SqlServer –Pre
Install-Package Microsoft.EntityFrameworkCore.Tools –Pre
Install-Package Microsoft.EntityFrameworkCore.SqlServer.Design –Pre

Later I can create my model from a database with this command:

Scaffold-DbContext "'Server=(localdb)\mssqllocaldb;Database=Blogging;Trusted_Connection=True;'" Microsoft.EntityFrameworkCore.SqlServer

The problem is that if I exit VS2015 and open again, if I have tried to run the same command to generate again the models, I get this error:

The term 'Scaffold-DbContext' is not recognized as the name of a cmdlet.

I don't know what is the problem, I have tried to install the entityFrameworks.Commands but the problem is not solved.


Solution

  • Have you tried the command:

    dotnet restore --infer-runtimes
    

    For more information, you can visit: https://github.com/aspnet/EntityFramework/issues/5549, it worked for someone.