Cannot use 'dotnet ef...' - The specified framework version '2.0' could not be parsed

I finally found the answer after going through some issues on GitHub.

It looks like it is an issue with dotnet CLI itself, not EF core.

If you are facing this issue, please update your .csproj file to include runtime framework version: (at the time of writing this post I have 2.0.5 installed, but check which version you have and use correct one which you have on your machine.

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
  </PropertyGroup>

It solves the issue properly. To me it looks like without specified version in csproj file, dotnet CLI is trying to fall back to 2.0.0 which most of us don't have on computers because of the updates.


There can also be another issue. If you are missing the Microsoft.EntityFrameworkCore.Design NuGet package, you will get the same error. So make sure you have this NuGet package referenced from the project where you want to run migrations.


Adding this to the .csproj file solved it for me, following this thread on Github:

<PropertyGroup>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>