CorrieJanse
CorrieJanse

Reputation: 2598

The EntityFramework package is not installed on project even though it is

I first had this issue after new version of EntityFramework came out. It says I could not Add-Migration because The EntityFramework package is not installed on project . Now before links This Answer. It's not that - see below:

enter image description here

And it is absolutely installed:

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

  <PropertyGroup>
    <TargetFramework>net6.0</TargetFramework>
    <ImplicitUsings>enable</ImplicitUsings>
    <Nullable>enable</Nullable>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.3" />
    <PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.3">
      <PrivateAssets>all</PrivateAssets>
      <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
    </PackageReference>
    <PackageReference Include="Microsoft.Extensions.Caching.SqlServer" Version="6.0.3" />
    <PackageReference Include="System.Linq.Expressions" Version="4.3.0" />
  </ItemGroup>

  <ItemGroup>
    <ProjectReference Include="..\Discounted.Models\Discounted.Models.csproj" />
  </ItemGroup>

</Project>

I originally fixed this issue by updating the packages.

I have tried:

Upvotes: 0

Views: 2333

Answers (2)

Ragab Mohamad
Ragab Mohamad

Reputation: 708

Oh my God I Solved It....In Visual Studio 2022 , you must Install NGet Packages are important .

NUGET Packages

  1. EntityFramework - Version 6.4.4 .
  2. Microsoft.EntityFrameworkCore - Version 6.0.11.
  3. Microsoft.EntityFrameworkCore.Relational - Version 6.0.11
  4. Microsoft.EntityFrameworkCore.SqlServer - Version 6.0.11
  5. Microsoft.EntityFrameworkCore.Design - Version 6.0.11
  6. Microsoft.EntityFrameworkCore.Tools - Version 6.0.11

I used code first approach ... My Error

enter image description here

Follow ME:

PM> EntityFrameworkCore\Add-Migration
cmdlet Add-Migration at command pipeline position 1
Supply values for the following parameters:
Name: "Initial-Migraion"

enter image description here

PM> EntityFrameworkCore\Update-Database
Both Entity Framework Core and Entity Framework 6 are installed. The Entity Framework Core tools are running. Use 'EntityFramework6\Update-Database' for Entity Framework 6.
Build started...
Build succeeded

enter image description here

.

Upvotes: 1

CorrieJanse
CorrieJanse

Reputation: 2598

There was two versions of Entity Framework Installed. After uninstalling the regular EF I had to restart visual studio to get it working.

Upvotes: 2

Related Questions