Reputation: 2598
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:
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
Reputation: 708
Oh my God I Solved It....In Visual Studio 2022 , you must Install NGet Packages are important .
I used code first approach ... My Error
Follow ME:
PM> EntityFrameworkCore\Add-Migration
cmdlet Add-Migration at command pipeline position 1
Supply values for the following parameters:
Name: "Initial-Migraion"
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
.
Upvotes: 1
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