EntityFramework Core 2.0 - Add Migration error "The EntityFramework package is not installed"

the entityframework package is not installed on project entity framework core
add-migration ef core
revert migration ef core
ef core 3 migrations
ef core disable migrations
no add migration
add-migration myfirstmigration
both entity framework core and entity framework 6 are installed

I'm getting an error when trying to Add Migration for Entity Framework Core, to a Code First project, here's the details...

I have created a new ASP.Net Core web project (Core 2.0 in VS 2017). Its using the Microsoft.AspNetCore.All dependency, shown below:

I am looking to utilise the Entity Framework Core (my understanding was that the All meta data had the EF Core dependencies included already, shown below, looks to be correct):

I've setup my entities and context and I've ensured the db is setup using the following code.

Example Model

public class City
    public int Id { get; set; }

    public string Name { get; set; }

    public string Description { get; set; }

Example Context

public class CityInfoContext : DbContext
    public DbSet<City> Cities { get; set; }
    public DbSet<PointOfInterest> PointsOfInterest { get; set; }

    public CityInfoContext(DbContextOptions options) : base(options)

Startup.cs Config

public void ConfigureServices(IServiceCollection services)
    .AddMvcOptions(options => {
        options.OutputFormatters.Add(new XmlDataContractSerializerOutputFormatter());
    .AddJsonOptions(options => {
        if (options.SerializerSettings.ContractResolver != null)
            var res = options.SerializerSettings.ContractResolver as DefaultContractResolver;
            res.NamingStrategy = null;

    services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
    services.AddSingleton<IMailService, LocalMailService>();

    // Entity Framework services.
    var connectionString = @"Server=(localdb)\mssqllocaldb;Database=CityInfoDB;Trusted_Connection=True;";
    services.AddDbContext<CityInfoContext>(options => options.UseSqlServer(connectionString));

Initializing the db conext with this line in my controller:

public class DummyController : Controller
    CityInfoContext _ctx;

    public DummyController(CityInfoContext ctx)
        _ctx = ctx;

I can see the db is created successfully - all good so far.

I want to take a snapshot of my db using this command: PM> Add-Migration CityInfoInitialMigration

But get the error: The EntityFramework package is not installed on project 'CityInfo.API'.

Has anyone came across this before? I explicitly tried adding the EF packages but that didn't work either!

NPM> Get-Module

If the result contains EntityFramework

ModuleType Version    Name                                ExportedCommands                                                                                                                                                                                         
---------- -------    ----                                ----------------                                                                                                                                                                                         
Script    EntityFramework                     {Add-    EFDefaultConnectionFactory, Add-EFProvider, Add-Migration, Enable-Migrations...}                                                                                                                    
Script     2.0.0      EntityFrameworkCore                 {Add-Migration, Drop-Database, Enable-Migrations, Get-DbContext...}                                                                                                                                      
Script    NuGet                               {Add-BindingRedirect, Find-Package, Get-Package, Get-Project...}                                                                                                                                         
Script     0.0        profile                                                                                                                                                                                                                                      

Meaning both EntityFrameworkCore and EntityFramework Nuget packages are installed in a project and that causes

The EntityFramework package is not installed

In my case, I was referencing some Nuget package which was referencing EntityFramework 6.0.0 (so EntityFramework package was referenced indirectly). After removing that package, the error was fixed.

The easiest way to find such reference is using Search Solution Explorer dialog

[SOLVED] - EntityFramework Core 2.0, I was able to get past this issue using the command-line-interface, by following article:. I have created a new ASP.Net Core web project (Core 2.0 in VS 2017). Its using the Microsoft.AspNetCore.All dependency, shown below: I am looking to utilise the Entity Framework Core (my understanding was that the All meta data had the EF Core dependencies included already, shown below, looks to be correct):

Make sure you have Microsoft.EntityFrameworkCore.Tools package installed. This package defines the PMC commands for EF Core.

Entity Framework Core Errors Using Add-Migration – Eric L. Anderson, Entity Framework Core Errors Using Add-Migration week's post and hit some issues when trying to add a migration for a new DbContext. NET Core 2.0 from scratch using the Visual Studio 2017 new project wizard did not  Entity Framework Core 2.0 Add-Migration doesn't create any migration files core-migrating-and.html. PM> Add-Migration GradePremade -project Mfc.MfcRepositoryModel

I was able to get past this issue using the command-line-interface, by following article:


[SOLVED], @JulieLerman provided the answer when I asked in her pluralsight course discussion. There is apparently an issue with attempting this with  Update: So I went ahead and manually created the AccountTypes table. Add-Migration works since it doesn't fail on the select statement. However running Update-Database fails because, like Add-Migration, it first does a select on my AccountTypes table and then tries to create the AccountTypes table of course it's going to fail.

Cannot make migration. ef core 2.0 · Issue #9415 · dotnet/efcore , dotnet-ef command missing -e (environment) option, that is required in my project​. dotnet ef migrations add Test -c BackendContext -v. Error Entity Framework Core 2.0 - Add-Migration não funciona. Faça uma pergunta Perguntada 2 anos, 2 meses atrás. Estou usando dot.net core 2.0 e C# 7.2.

Add-migration fail after upgrade to 2.0.0 · Issue #9891 · dotnet/efcore , When I upgraded to Entityframework core 2.0. It started to show me error, when I want to create migration (by command "add-migration"). Empty migrations. Sometimes it's useful to add a migration without making any model changes. In this case, adding a new migration creates code files with empty classes. You can customize this migration to perform operations that don't directly relate to the EF Core model. Some things you might want to manage this way are: Full-Text Search

Tutorial: Using the migrations feature, In this tutorial, you start using the EF Core migrations feature for In later tutorials, you'll add more migrations as you change the data model. If you see an error message No executable found matching command "dotnet-ef",  После того же Pluralsight видео, я столкнулся с этой же проблемой. После бега: PM> install-package Microsoft.EntityFrameworkCore.SqlServer

  • It looks like the EF6 PMC commands are running... What does Get-Module say is loaded?
  • Extending on from this, if you have both EntityFramework and EntityFrameworkCore modules installed, you can specifiy which module you would like to execute the "add-Migration" command with by specifying: EntityFrameworkCore\Add-Migration <Migration-Name> -Project <ProjectName> -StartupProject <StartUpPRojectName> -Context <DbContext-Name>
  • @TristanvanDam nice addon Tristan
  • @TristanvanDam Thanks. This is annoying with .NET Core 3.0 I am having to do EntityFrameworkCore\ before all migrations and updates to the database. I do not have EntityFramework installed. When I attempt to remove package through the CLI it says it doesn't exist. There is a reference though in AssemblyReferenceCache that seems to be coming from Microsoft.AspNet.Identity.EntityFramework or EntityFramework.SQLServer, do you know why VS thinks EntityFramework is installed? Is this a .NET Core 3.0 issue?
  • @tchelidze To complete your steps in my case, visual studio must be restarted to clean the cache of the conflicted Entity Framework version. Thank you...
  • Running Get-Modules shows i have both installed like your 1st image above (ef v6.0.0 & ef.core 3.1.0 ) I cant find any ef v6 packages in Dependencies and I cant run Unistall-Package on ef v6 I get 'Entity Framework could not be found' error - when I run Add-Migration test, I get the message 'Both EF Core & EF 6 are installed.' Then I run Update-Database and I get SQLite error'table AspNetRoles' already exists. Any pointers how I can remove ef6? Thanks
  • Thanks for sharing your question and answer!
  • @RobMcCabe, any solution without using cli ?
  • This is not the exact answer, alternative way of using Command Windows and calling EF.
  • Feel free to add the exact answer Zin - the more information shared, the more chance it can help others! Thanks for the feedback!