Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

My project builds without any issues and can run without issues, but I cannot use dotnet ef migrations because of this strange error:

The specified framework version '2.0' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.0' was not found.
  - Check application dependencies and target a framework version installed at:
      /
  - Alternatively, install the framework version '2.0'.

I have latest dotnet tooling installed - SDK 2.1.4 and runtime 2.0.5.

Can anyone help with that? I was trying to find any solutions on web but didn't find anything working...

like image 395
Marek Urbanowicz Avatar asked Feb 03 '18 00:02

Marek Urbanowicz


3 Answers

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.

like image 82
Marek Urbanowicz Avatar answered Nov 12 '22 01:11

Marek Urbanowicz


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.

like image 10
Marius Stănescu Avatar answered Nov 12 '22 02:11

Marius Stănescu


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

<PropertyGroup>
    <GenerateRuntimeConfigurationFiles>true</GenerateRuntimeConfigurationFiles>
</PropertyGroup>
like image 4
Narvalex Avatar answered Nov 12 '22 01:11

Narvalex