“Build failed” on Database First Scaffold-DbContext

后端 未结 18 1668
醉梦人生
醉梦人生 2020-12-24 04:31

I\'m trying to generate classes from a database (EntityFramework\'s database first approach).

For convenience, I\'m more or less walking along with this tutorial: ht

18条回答
  •  攒了一身酷
    2020-12-24 05:07

    Using VS2017 Preview 3, .NET Core 2 (PREVIEW) I had all sorts of issues, but eventually I took the approach suggested above and created a brand new solution.

    1. Created new .NET Core solution
    2. Edited project file and changed 1.0 to 2.0: netcoreapp2.0
    3. Closed/re-opened solution

    Then, added the Entity Framework:

    1. In PackageManager console:
      • Install-package Microsoft.EntityFrameworkCore.SqlServer -Version 2.0.0-preview2-final
      • Install-package Microsoft.EntityFrameworkCore.Tools -Version 2.0.0-preview2-final
      • Install-package Microsoft.EntityFrameworkCore.Design -Version 2.0.0-preview2-final
    2. Edited project file, and added:

    Then;

    1. Opened the Powershell command prompt and changed directory into Scaffold project folder
    2. Ran: dotnet ef dbcontext scaffold "Server=DESKTOP-MB70B7U; Database=ForexForme; Trusted_Connection=True" Microsoft.EntityFrameworkCore.SqlServer -o Models
      • Where you put in your own connection string!
      • Models is the name of my directory where I put all my classes

提交回复
热议问题