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

EF Framework Tools try to build with old SDK #27385

Closed
SebastianStehle opened this issue Feb 7, 2022 · 7 comments
Closed

EF Framework Tools try to build with old SDK #27385

SebastianStehle opened this issue Feb 7, 2022 · 7 comments
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported

Comments

@SebastianStehle
Copy link

SebastianStehle commented Feb 7, 2022

Ask a question

I have a DBContext in a class library for which I want to add migrations:

dotnet ef migrations add CreateInitial -o Db\Sql\Migrations

When I execute this command I get the following output in Powershell:

Build started...
Build succeeded.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.
  - The following frameworks were found:
      3.1.2 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      3.1.7 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      5.0.8 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
      6.0.0 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]

You can resolve the problem by installing the specified framework and/or SDK.

The specified framework can be found at:
  - https://aka.ms/dotnet-core-applaunch?framework=Microsoft.NETCore.App&framework_version=2.0.0&arch=x64&rid=win10-x64

But the project builds find and the csproj looks like this (shortened)

<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <LangVersion>10.0</LangVersion>
    <Nullable>enable</Nullable>
    <ImplicitUsings>enable</ImplicitUsings>
  </PropertyGroup>
  <ItemGroup>
    <FrameworkReference Include="Microsoft.AspNetCore.App" />
  </ItemGroup>
  <ItemGroup>
    <PackageReference Include="System.Threading.Tasks.Dataflow" Version="6.0.0" />
	...
  </ItemGroup>
  <ItemGroup>
    <ProjectReference Include="..." />
	...
  </ItemGroup>
</Project>

The verbose output does not show more information.

What am I doing wrong?

Include provider and version information

EF Core version: 6.0.1
EF Core Tools version: 6.0.1
Database provider: (e.g. Microsoft.EntityFrameworkCore.SqlServer): MySql
Target framework: 6.0.0
Operating system:
IDE: (e.g. Visual Studio 2019 16.3)

@ajcvickers
Copy link
Member

ajcvickers commented Feb 7, 2022

@SebastianStehle ASP.NET Core 3.0 and later require that "Microsoft.AspNetCore.App" be removed. See Migrate from ASP.NET Core 2.2 to 3.0

@SebastianStehle
Copy link
Author

SebastianStehle commented Feb 7, 2022

But it is a class library and documented here to be the correct approach: https://docs.microsoft.com/en-us/aspnet/core/fundamentals/target-aspnetcore?view=aspnetcore-6.0&tabs=visual-studio

As i said: It builds and runs fine.

If I use powershell and go to the project folder:

dotnet build // Works fine
dotnet ef migrations add CreateInitial -o Db\Sql\Migrations // Fails with build error

@ajcvickers
Copy link
Member

/cc @bricelam

@lotsahelp
Copy link

I'm having the same issue with v6.0.2 trying to scaffold.

`Build started...
Build succeeded.
It was not possible to find any compatible framework version
The framework 'Microsoft.NETCore.App', version '2.0.0' (x64) was not found.

  • The following frameworks were found:
    3.1.19 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    3.1.20 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    3.1.22 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    5.0.13 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
    6.0.1 at [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]`

@lotsahelp
Copy link

Installing .NET Core 2.2 Runtime (v2.2.8) allowed me to continue, but I'd rather not install an unsupported runtime.

@SebastianStehle
Copy link
Author

The fix is to add Microsoft.EntityFrameworkCore.Design to your project. At least works for me. But it is weird.

@bricelam
Copy link
Contributor

The fix is to add Microsoft.EntityFrameworkCore.Design to your project.

This effectively adds the following to your csproj. Adding it directly should also work around the issue.

<PropertyGroup>
  <GenerateRuntimeConfigurationFiles>True</GenerateRuntimeConfigurationFiles>
</PropertyGroup>

Issues #14531 and #18840 will also address this limitation.

@AndriySvyryd AndriySvyryd added the closed-no-further-action The issue is closed and no further action is planned. label Feb 11, 2022
@ajcvickers ajcvickers reopened this Oct 16, 2022
@ajcvickers ajcvickers closed this as not planned Won't fix, can't repro, duplicate, stale Oct 16, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-no-further-action The issue is closed and no further action is planned. customer-reported
Projects
None yet
Development

No branches or pull requests

5 participants