14

I have framework version set to: dnx46 in project.json. Also have the following packages:

  "dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.Core": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final"
  }

However when I got into running enable-migrations command I get the following:

The term 'enable-migrations' is not recognized as the name of a cmdlet

Does anyone know how I get EF migrations running in latest .NET?

0

8 Answers 8

26

This is what worked for me to solve this issue:

Run:

Install-Package Microsoft.EntityFrameworkCore.Tools –Pre

In project.json add this (if not there already) to the "tools" section:

"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview4-final",

Useful reference: https://docs.efproject.net/en/latest/platforms/aspnetcore/new-db.html

3
  • 1
    So is this now working? I was told it wasn't supported (see below answer).
    – user183872
    Commented Sep 6, 2016 at 13:06
  • Yes, it is working for me with Visual Studio Community 2015 Version 14.0.25425.01 Update 3 with Microsoft.EntityFrameworkCore.Tools version 1.0.0-preview2-final Commented Sep 7, 2016 at 0:59
  • 3
    This worked for me eventually. I had to restart VS and delete my project.lock.json file. Commented Sep 11, 2016 at 11:06
6

As ErikEJ mentioned, there is no "enable-migrations". You will need to use "Add-Migrations" instead. See official docs for EF Core's Powershell commands here: http://docs.efproject.net/en/latest/cli/powershell.html

There appears to be a bug in NuGet and Package Manager Console in some versions of Visual Studio. If cmdlets are not recognized after adding the Commands package, try restarting VS.

Also, dnx commands will not be supported after RC1. New (forthcoming) dotnet tooling will be available for RC2. See https://github.com/aspnet/EntityFramework/issues/3925

4
  • The add-migration still isn't working even after a reboot. I'm happy sticking with PowerShell but it surprises me that the dnx commands are no longer supported as Visual Studio Code would need this kinda of tooling wouldn't it?
    – user183872
    Commented Feb 4, 2016 at 23:20
  • dnx commands will be replaced by dotnet commands. They will work almost the same, so VS Code users will still have EF tooling. Commented Feb 5, 2016 at 0:41
  • Which OS version do you use?
    – ErikEJ
    Commented Feb 5, 2016 at 5:22
  • Microsoft solution still working nowadays (re start VS)
    – AFetter
    Commented Sep 20, 2016 at 0:17
5

The only way I managed to get EntityFrameworkCore.Tools (which includes Add-Migration) working with the latest EF Core & VS 2015 was to manually call the init script from the Package Manager Console like so:

PM> %UserProfile%\.nuget\packages\Microsoft.EntityFrameworkCore.Tools\1.0.0-preview1-final\tools\init.ps1
1

To add a new migration in EF7 use this command :

dnx ef migrations add YourMigrationUniqueName
0

There is no "enable-migrations" command in EF Core (EF7).

Just use "add-Migration"

4
  • Is this in PowerShell console or the new DNX tools?
    – user183872
    Commented Feb 3, 2016 at 16:08
  • PM> add-migration add-migration : The term 'add-migration' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
    – user183872
    Commented Feb 4, 2016 at 23:17
  • Powershell doesn't seem to like the command. I've got EntityFramework.Commands installed so not sure whats going on.
    – user183872
    Commented Feb 4, 2016 at 23:18
  • 1
    I've added a ticket on GitHub as a bug because this is certainly not working out of the box,
    – user183872
    Commented Feb 4, 2016 at 23:31
0

Currently EF migrations are not supported out of the box:

https://github.com/aspnet/EntityFramework/issues/4497

0

I Haved the same probleam, i was using the PowerShell for the comand, but he work in Package Manager Console.

Try to run in -> Tools -> NuGet Package Manager -> Package Manager Console

0

Eu tive um problema parecido quando utilizei o powershell, quando utilizei o terminal do nuget funcionou. Achei a solução no link https://github.com/dotnet/efcore/issues/4497#issuecomment-1066867723

No Visual Studio: Ferramentas -> Gerenciador de Pacotes NuGet -> Console do Gerenciador de Pacotes

Rodar o comando add-migration

1
  • language must be English
    – Emre Bener
    Commented Jul 19, 2023 at 13:02

Not the answer you're looking for? Browse other questions tagged or ask your own question.