Problem

Here is the basic setup of this problem:

  1. You created a .Net Core application and wanted to use .Net Core EF in your application for the data layer.
  2. You have already installed .Net Core EF from NuGet
  3. You setup your data layer using Fluent API
  4. You are ready for adding your initial migration, but using the .Net CLI keeps giving you a bogus error like the one shown below after running the following command:

dotnet ef migrations add InitialCreate

Gotcha

From what I have seen there are a few steps to remedy this problem and it isn’t obvious if you are new to .Net Core at all. I got most of my information by cross referencing articles and blog posts, but this one explains it well: https://github.com/dotnet/core/issues/1843

How to fix the stupid problem

Add the XML that is between the “PropertyGroup” tags to your project file that is referencing the Entity Framework NuGet package.

If at this point you were to run the “dotnet ef migrations add InitialCreate” command again you would get the following error:

That being said the next step according to the error is to add the missing NuGet package “Microsoft.EntityFrameworkCore.Design” to your project.

At this point when you run the “dotnet ef migrations add InitialCreate” command again you could run into more issues, but it is all first time setup of your context class. I could keep listing possibilities, but this would be a never ending article at that point, most of which is covered by google.

.Net EF Core migrations instructions

My rant you can ignore

It’s obvious .Net Core is still under developed to be having problems like this. Microsoft needs to hurry the hell up and get things up to par to .Net Framework; I feel like it’s been long enough at this point. I am never one to jump on the bandwagon early just so I can say I am doing something, especially not at the cost of inconvenience spent as time debugging their mistakes.

 

Leave a Reply

Your email address will not be published. Required fields are marked *