Getting compile error when trying to add migrations

NOVATROOP77 266 Reputation points
2021-08-09T20:52:11.973+00:00

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?

Developer technologies | .NET | Entity Framework Core
Developer technologies | C#
{count} votes

2 answers

Sort by: Most helpful
  1. Sam of Simple Samples 5,546 Reputation points
    2021-08-10T00:16:01.957+00:00

    When you right-click the project and select Manage Nuget Packages what packages are installed? If not EntityFramework then install it.

    0 comments No comments

  2. Daniel Zhang-MSFT 9,656 Reputation points
    2021-08-10T01:53:20.987+00:00

    Hi davidbuckley-4911,
    I have some suggestions you can refer to.

    1. Restart Visual Studio.
    2. 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.
    3. 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.
    4. 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.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.