Thursday, October 4, 2018

Make a first migration in an EF Core application.

After you set up the connection string you need to do this. Pages 178 and 179 of "ASP.NET Core 2 and Angular 5" by Valerio De Sanctis touch on this. First open (in Notepad) the .csproj file for the appropriate project that has Microsoft.EntityFrameworkCore line items (Microsoft.EntityFrameworkCore, Microsoft.EntityFrameworkCore.SqlServer, Microsoft.EntityFrameworkCore.SqlServer.Design, Microsoft.EntityFrameworkCore.Tools, Microsoft.EntityFrameworkCore.Tools.DotNet) in the ItemGroup XML block and change PackageReference to DotNetCliToolReference for each one. This may need to bleed up to the UI project in Onion Architecture which really sucks. Maybe there is a way out of that. I don't know yet. Anyhow, then run the PowerShell shell as Administrator and navigate to the folder holding Startup.cs and run then commands:

  1. dotnet restore
  2. dotnet ef
  3. dotnet ef migrations add "Initial" -o "OneFolderDeep\AnotherFolder"

 
 

Addendum 10/6/2018: There may be more than one ItemGroup block in the .csproj file.

No comments:

Post a Comment