sdk icon indicating copy to clipboard operation
sdk copied to clipboard

The specified framework version '2.1' could not be parsed The specified framework 'Microsoft.NETCore.App', version '2.1' was not found.

Open aherrick opened this issue 8 years ago • 18 comments

Just now seeing this error when trying to run update-database from PM console. I have the latest SDK installed.

I've tried repairing VS2017 and also uninstalling/reinstalling the latest .NET Core SDK.

What am I doing wrong here?

PM> update-database
The specified framework version '2.1' could not be parsed
The specified framework 'Microsoft.NETCore.App', version '2.1' was not found.
  - Check application dependencies and target a framework version installed at:
      C:\Program Files\dotnet\
  - Installing .NET Core prerequisites might help resolve this problem:
      http://go.microsoft.com/fwlink/?LinkID=798306&clcid=0x409
  - The .NET Core framework and SDK can be installed from:
      https://aka.ms/dotnet-download
  - The following versions are installed:
      2.0.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.0.9 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.3 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.4 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      2.1.5 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

image

image

aherrick avatar Oct 05 '18 15:10 aherrick

@bricelam can you comment? I am not familiar with how this update-database command interacts with core.

livarcocc avatar Oct 05 '18 16:10 livarcocc

@aherrick What version of Microsoft.EntityFrameworkCore.Tools is installed? What is the output with -Verbose?

bricelam avatar Oct 05 '18 17:10 bricelam

@bricelam thanks for the response. How can I figure that out?

aherrick avatar Oct 05 '18 17:10 aherrick

C:\Users\aherrick>dotnet ef --version
Entity Framework Core .NET Command-line Tools
2.1.4-rtm-31024

aherrick avatar Oct 05 '18 17:10 aherrick

Running update-database -verbose is probably enough. I think it shows the version

bricelam avatar Oct 05 '18 17:10 bricelam

Build started...
Build succeeded.
C:\Users\aherrick\.nuget\packages\microsoft.entityframeworkcore.tools\2.1.4\tools\netcoreapp2.0\any\ef.dll

aherrick avatar Oct 05 '18 18:10 aherrick

This project was originally a netstandard2.0 project, and we just moved it to netcoreapp2.1 would that have anything to do with it?

aherrick avatar Oct 05 '18 18:10 aherrick

@bricelam is there anything else we need to look here? Is this something the CLI/SDK is doing wrong?

livarcocc avatar Oct 09 '18 18:10 livarcocc

Hey all - I believe we figured this out. Our issue was we did have the correct project selected in PM, however the correct Project in the solution wasn't set as Startup. Once I set the actual Core Web project as Startup, it worked. Confusing to say the least!

Thanks for the help anyway!

aherrick avatar Oct 09 '18 18:10 aherrick

I am facing the same error. My ef version is as below:

PS C:\Users\rsrivastava\source\accounting\api> dotnet ef --version Entity Framework Core .NET Command-line Tools 2.1.2-rtm-30932

rahul5163 avatar Oct 10 '18 14:10 rahul5163

adding below in csproj resolved it for me.

<RuntimeFrameworkVersion>2.1.0</RuntimeFrameworkVersion>

rahul5163 avatar Oct 10 '18 15:10 rahul5163

Similar issue here, I took a version specifically from the "The following versions are installed" and did what @rahul5163 said but put in the latest version I had there:

<RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>

That helped.

Rene-Sackers avatar Oct 11 '18 16:10 Rene-Sackers

aherrick's comment: "the correct Project in the solution wasn't set as Startup. Once I set the actual Core Web project as Startup, it worked." This was true for me, too. Once I set the project that held the DBContext class as the "startup project"; i.e., right-click the project and choose "Set as Startup Project", the initial migration worked just fine. But this project is also a class library, so some other adjustments will need to be made since I will eventually need a UI as the startup project vs. a class library.

Loves2Code avatar Oct 11 '18 16:10 Loves2Code

I had to change the startup project to something else rather than Core project to make it work

elnoor avatar Oct 26 '18 06:10 elnoor

Where exactly in the csproj file am I supposed to add <RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>?

Does it go in the <PropertyGroup>?

agray avatar Oct 29 '18 04:10 agray

Had the same issue. This

Check application dependencies and target a framework version installed at

is a clue on what to do next. So, I added <RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion> and got output like this

Your startup project 'App.Database.Migrations.MySql' doesn't reference Microsoft.EntityFrameworkCore.Design. This package is required for the Entity Framework Core Tools to work. Ensure your startup project is correct, install the package, and try again.

So the problem actually was a missing reference to Microsoft.EntityFrameworkCore.Design package. Actually no need for the <RuntimeFrameworkVersion>2.1.5</RuntimeFrameworkVersion>.

featherbits avatar Nov 05 '18 14:11 featherbits

Had the same issue here even after adding the <RuntimeFrameworkVersion>. It seems that in some cases you don't only have to build the project to work but also run it once before trying to use ef commands.

MightyLoggor avatar Nov 14 '18 05:11 MightyLoggor

I stumbled upon this problem when trying to generate new migration with Add-Migration command. I just used dotnet ef migrations add Initial --project .\DatabaseProject\DatabaseProject.csproj --startup-project .\WebAppProject\WebAppProject.csproj instead. Note that DatabaseProject must be referenced by WebAppProject in order to make it work.

// edit: my CLI tools version is Entity Framework Core 2.1.4-rtm-31024

JachuPL avatar Nov 28 '18 09:11 JachuPL