Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't create EF migrations after installing .NET 6

I've just installed .NET 6 SDK and updated all my projects to use target net6.0, but when I try to create a new migration with the dotnet tool I get:

.csproj

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
    <ApplicationIcon>assets-logo.ico</ApplicationIcon>
    <RootNamespace>LC.Assets</RootNamespace>
    <Authors>Stein Lundbeck</Authors>
    <Company>Lundbeck Consulting</Company>
    <Product>LC Assets</Product>
    <Copyright>2021</Copyright>
  </PropertyGroup>

  <ItemGroup>
    <Content Include="assets-logo.ico" />
  </ItemGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\LC.Components.Core\LC.Components.Core.csproj" />
    <ProjectReference Include="..\LC.Components\LC.Components.csproj" />
  </ItemGroup>

</Project>

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:
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.

I've updated the dotnet-ef tool to version 6.0.0, so I don't know what it is that still target the 2.0.0 version.

Tool 'dotnet-ef' was successfully updated from version '5.0.4' to version '6.0.0'.

Any ideas?

like image 797
SteinTheRuler Avatar asked Dec 30 '25 17:12

SteinTheRuler


1 Answers

I just ran into the exact same issue.

Rather than installing Microsoft.NETCore.App 2.0.0., I installed the Entity Framework Core Design package:

dotnet add package Microsoft.EntityFrameworkCore.Design

It made the error go away for me.

Note: I came upon the solution after remembering that following the EF Getting Started guide (https://learn.microsoft.com/en-us/ef/core/get-started/overview/first-app?tabs=netcore-cli) had me install the Design package and didn't throw the error when I followed the guide.

like image 189
Thomas Z Avatar answered Jan 05 '26 07:01

Thomas Z



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!