Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with dotnet cli ef tools after upgrading to vs 2017 15.4.4 and november .net core rollup #10298

Closed
spnm opened this Issue Nov 15, 2017 · 34 comments

Comments

Projects
None yet
@spnm
Copy link

spnm commented Nov 15, 2017

Not sure if its an EFCore issue or cli

Steps to reproduce

Using Visual Studio Enterprise 2017 (v 15.4.4)

Add migration

dotnet ef migrations add [MigrationName]

Expected behavior

Migration created

Actual behavior

Error message :
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'.

My project is a console library and the content of .csproj file is below:

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
  </PropertyGroup>
  
  <ItemGroup>
    <PackageReference Include="System.Reflection.Metadata" Version="1.5.0" />
    <PackageReference Include="Microsoft.Extensions.Configuration" Version="2.0.0" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="2.0.1" PrivateAssets="All" />
  </ItemGroup>
  
  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
  </ItemGroup>
</Project>

So i tried to use global.json in the root of my project :

{
  "sdk": {
    "version": "2.0.3"
  }
}

and the error was the same.
But when I changed global.json content to this :

{
  "sdk": {
    "version": "2.0.2"
  }
}

It worked.

@spnm spnm changed the title The specified framework version '2.0' could not be parsed Problem with dotnet cli ef tools after upgrading to vs 2017 15.4.4 and november .net core rollup Nov 15, 2017

@dalibor983

This comment has been minimized.

Copy link

dalibor983 commented Nov 15, 2017

I have the same problem.

@marcwmiller

This comment has been minimized.

Copy link

marcwmiller commented Nov 15, 2017

I have same issue.

@lccarvalho

This comment has been minimized.

Copy link

lccarvalho commented Nov 15, 2017

Scaffold-DbContext fails silently after that same upgrade to VS 15.4.4

@Wind010

This comment has been minimized.

Copy link

Wind010 commented Nov 16, 2017

I have the same predicament.

Error is occurring when running:
dotnet ef migrations remove

I was able to work around this by adding this to the EF project:

<PropertyGroup>
   <TargetFramework>netcoreapp2.0</TargetFramework>
   <RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
</PropertyGroup>
@alexzaytsev-newsroomly

This comment has been minimized.

Copy link

alexzaytsev-newsroomly commented Nov 16, 2017

Can confirm that 2.0.2 workaround works. Not really clear why.

@jorgeyanesdiez

This comment has been minimized.

Copy link

jorgeyanesdiez commented Nov 16, 2017

I am pretty sure this is a CLI (dotnet tools) problem, not an EF problem, since I get the same error with dotnet xunit in powershell.

I have cleaned up my system, and only have the 2.0.3 SDK, runtime (x64 and x86) and windows server hosting packs, therefore, @spnm 's solution doesn't work, but @Wind010 's does.

@jorgeyanesdiez

This comment has been minimized.

Copy link

jorgeyanesdiez commented Nov 16, 2017

This is probably a dupe of dotnet/cli#7901

@ajcvickers

This comment has been minimized.

Copy link
Member

ajcvickers commented Nov 16, 2017

@Eilon @natemcmaster @livarcocc Any ideas on this?

@livarcocc

This comment has been minimized.

Copy link

livarcocc commented Nov 16, 2017

I have been trying to repro this for a while now without much success, but this does seem like a CLI problem.

@livarcocc

This comment has been minimized.

Copy link

livarcocc commented Nov 16, 2017

This is a CLI/SDK bug that we now understand. I am duping this one to the one in the CLI: dotnet/cli#7901

We will explain it there why this happens and a workaround and we are figuring out the vehicle to carry a fix for this.

@ajcvickers can you close this bug?

@ajcvickers

This comment has been minimized.

Copy link
Member

ajcvickers commented Nov 16, 2017

Thanks @livarcocc. Closing.

@bricelam

This comment has been minimized.

Copy link
Member

bricelam commented Nov 16, 2017

Re-opening since it looks like there's work to do on our side.

@bricelam bricelam reopened this Nov 16, 2017

@bricelam bricelam self-assigned this Nov 16, 2017

@heku

This comment has been minimized.

Copy link

heku commented Nov 17, 2017

The suggestion in comments don't work for netstandard2.0 project like below.

Windows 10 + VS 2017 15.4.4 + NetCore 2.0.3 SDK

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.0.1" />
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="2.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite.Core" Version="2.0.1" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
  </ItemGroup>

</Project>
@lccarvalho

This comment has been minimized.

Copy link

lccarvalho commented Nov 17, 2017

Neither for the 'Scaffold-DbContext' problem in a netcoreapp2.0 project

@marcwmiller

This comment has been minimized.

Copy link

marcwmiller commented Nov 17, 2017

I used the project config below, and it resolved the issue in my environment (Windows 10 + VS 2017 15.4.4 NetCore 2.0.3 SDK) for 'Scaffold-DbContext'

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework>
    <RuntimeFrameworkVersion>2.0.3</RuntimeFrameworkVersion>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="2.0.1" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="2.0.1" />
  </ItemGroup>

  <ItemGroup>
    <DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />
  </ItemGroup>
</Project>
@ajcvickers

This comment has been minimized.

Copy link
Member

ajcvickers commented Nov 17, 2017

@lccarvalho This sounds like it could be a different issue. Can you please file a new issue including a sample project that reproduces what you are seeing?

@heku .NET Standard class libraries are not supported directly by the EF tooling. You will need to target an actual framework (e.g. netcoreapp2.0) or specify a startup project that targets a framework. This issue is not about that, but about using a class library that targets on netcoreapp when there is no usable startup project.

@ajcvickers ajcvickers added this to the 2.0.4 milestone Nov 17, 2017

@bricelam

This comment has been minimized.

Copy link
Member

bricelam commented Nov 17, 2017

I've filed #10338 to improve the silently failing PMC commands.

@bricelam

This comment has been minimized.

Copy link
Member

bricelam commented Nov 17, 2017

Workaround

Adding the following to the project should also make it work.

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

@bricelam bricelam closed this in 9d34aa0 Nov 30, 2017

@Eilon

This comment has been minimized.

Copy link
Member

Eilon commented Dec 1, 2017

Keeping the issue open for tracking purposes.

@68681395

This comment has been minimized.

Copy link

68681395 commented Dec 12, 2017

There is the same problem with my project, the workaround to resolve it successfully is that remove the item 'C:\Program Files (x86)\dotnet' from the Path of Environment Variable because I found I did not install the right netcore version under X86. I have not tried to install the proper version with x86, appreciate that you tell me if you have done that test.

@Eilon

This comment has been minimized.

Copy link
Member

Eilon commented Jan 17, 2018

This patch is approved for the Feb 2018 patch. Please send a PR to the appropriate branch, get it reviewed, and merge.

Please consider adding a quirks-mode switch for this change.

@ivanruski

This comment has been minimized.

Copy link

ivanruski commented Jan 20, 2018

I found out that the dotnet cli commands can't run from ClassLibraries it needs .exe in order to execute the command. So I fixed my problem by adding new ConsoleApp (.NET Core) then I've added my ClassLibraries as references to the ConsoleApp. Then run the command dotnet ef --startup-project ../ConsoleApp migrations add init but failed with that Microsoft.EntityFrameworkCore.Design is required in order to execute the command I did it. And it worked

@bricelam bricelam closed this Jan 22, 2018

@gitfortee

This comment has been minimized.

Copy link

gitfortee commented Jan 30, 2018

@bricelam your workaround(link) has fixed the same kind of error i got.

Could you please help me understand what this setting does? could you provide some details on how it fixes the issue?

@bricelam

This comment has been minimized.

Copy link
Member

bricelam commented Jan 30, 2018

GenerateRuntimeConfigurationFiles forces a *.runtimeconfig.json file to be generated for the project. The file looks like this:

{
  "runtimeOptions": {
    "framework": {
      "name": "Microsoft.NETCore.App",
      "version": "2.0.0"
    }
  }
}

This tells dotnet to execute the code using a version of .NET Core compatible with 2.0.0.

Without the file, EF Tools pass --fx-version 2.0 to dotnet which forces it to run on .NET Core 2.0, but since it's missing a digit, it can't find it.

@bricelam

This comment has been minimized.

Copy link
Member

bricelam commented Jan 30, 2018

Setting RuntimeFrameworkVersion (as suggested by @Wind010) changes the value we pass to --fx-version. This will work; however, it means your app will require .NET Core version 2.0.3, so if you publish it to a server that only has version 2.0.0, it'll fail.

@gitfortee

This comment has been minimized.

Copy link

gitfortee commented Jan 30, 2018

thanks!

@cgountanis

This comment has been minimized.

Copy link

cgountanis commented Feb 27, 2018

Still getting this error via Core 2.1.4 SDK within ClassLibrary. When will we be able to add EF to these using NUGET vs. manually as well?

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />

dotnet ef migrations add InitialCreate
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'.

Does it not seem strange that I have to do this to get it to work on minor versions?

<PropertyGroup>
    <TargetFramework>netcoreapp2.0</TargetFramework
    <RuntimeFrameworkVersion>2.0.5</RuntimeFrameworkVersion>
</PropertyGroup>
@alexzaytsev-newsroomly

This comment has been minimized.

Copy link

alexzaytsev-newsroomly commented Feb 28, 2018

@cgountanis i still use the global.json workaround. but yeah, it is mighty annoying.

@ajcvickers

This comment has been minimized.

Copy link
Member

ajcvickers commented Feb 28, 2018

@cgountanis Unfortunately, the patch containing this fix has not yet been released. Release dates for patches is not something the EF team can influence very much, and there have been various reasons for delaying the patch release that are outside our control. I realize that this is frustrating and I apologize for that. We are, across .NET Core, working on making this process better, so hopefully it won't be such an issue going forward.

@cgountanis

This comment has been minimized.

Copy link

cgountanis commented Feb 28, 2018

Sounds good, will that fix the error when adding the tools via NUGET as well. Right now we have to add that line manually to do migrations etc...

<DotNetCliToolReference Include="Microsoft.EntityFrameworkCore.Tools.DotNet" Version="2.0.1" />

@ajcvickers

This comment has been minimized.

Copy link
Member

ajcvickers commented Feb 28, 2018

@cgountanis No, that's a separate NuGet issue, tracked here: NuGet/Home#4190

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.