1
votes

In Visual Studio 2017, create a .NET core class library project with Target Framework as 2.0.

Have included below packages by Package Manager console.

  1. Microsoft.EntityFrameworkCore.SqlServer

  2. Microsoft.EntityFrameworkCore.SqlServer.Design

  3. Microsoft.EntityFrameworkCore.Tools

  4. Microsoft.VisualStudio.Web.CodeGeneration.Design

While running below Scaffold-DbContext command from Package Manager console of the same project, getting Build Failed error.

Scaffold-DbContext "Data Source=HTGHTFG135611L;Initial Catalog=HHH;Persist Security Info=True;" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DBModels -force -v 

Also tried giving UserId and password, still the same error.

1
add your error pleasePouya Samie
PM> Scaffold-DbContext "Data Source=XXXXXXXX;Initial Catalog=HHH;Persist Security Info=True;User ID=XXXX;Password=XXXXX" Microsoft.EntityFrameworkCore.SqlServer -OutputDir DBModels -force -v -Tables Address,Household,Person,PersonRelationship,RelationshipType Using project 'HHH.DataModel'. Using startup project 'HHH.DataModel'. Build started... Build failed.user2181334
Also tried from windows power shell , below are the details :user2181334
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.user2181334
Do you get any errors manually building the project? (Ctrl+Shift+B)bricelam

1 Answers

4
votes

I had the same problem today, please be sure any project in your solution does not fail to build. Examine output folder after you got this error. I think one of your projects in your solution fails to build.