When you right-click the project and select Manage Nuget Packages what packages are installed? If not EntityFramework then install it.
Getting compile error when trying to add migrations
For some reason on a ef core 6 preview application that am testing with I am getting the following when I run the.
add-migration InitialMigration
I get the following error
The EntityFramework package is not installed on project 'Concierge.Dal'.
Even though as you can clearly see the tooling is installed into my project.
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="6.0.0-preview.6.21355.2" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="6.0.0-preview.6.21352.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Abstractions" Version="6.0.0-preview.6.21352.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="6.0.0-preview.6.21352.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Relational" Version="6.0.0-preview.6.21352.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.0-preview.6.21352.1" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.0-preview.6.21352.1">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
Can anyone tell me why am getting the above error. I have included my startup project in the services as would done in previous ef versions.
services.AddDbContext<ConciergeDBContext>
(options => options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")), ServiceLifetime.Transient);
Also when I try the old way version 6 below.
Add-Migration IMirgration -OutputDir "Data/Migrations" -Context ConciergeDBContext
It says that OutputDir is invalid are these braking changes in 6?
2 answers
Sort by: Most helpful
-
-
Daniel Zhang-MSFT 9,611 Reputation points
2021-08-10T01:53:20.987+00:00 Hi davidbuckley-4911,
I have some suggestions you can refer to.- Restart Visual Studio.
- Run Get-Module in the package manager console. If you see both EntityFramework and EntityFrameworkCore, you need to delete the EntityFramework or dependencies linked to EntityFramework. Then restart the project.
- In the package manager console, there is a "default project" drop-down menu. If the settings are not correct, you will get the EntityFramework package not installed on project "x". Change the drop-down list to your EF project.
- Or remove EntityFramework from all projects and reinstall it.
Best Regards,
Daniel Zhang
If the response is helpful, please click "Accept Answer" and upvote it.
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.