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?

user183872
  • 767
  • 2
  • 6
  • 20

8 Answers8

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

Ofer Zelig
  • 17,068
  • 9
  • 59
  • 93
Elijah Lofgren
  • 1,437
  • 3
  • 23
  • 39
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

Community
  • 1
  • 1
natemcmaster
  • 25,673
  • 6
  • 78
  • 100
  • 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 Feb 04 '16 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. – natemcmaster Feb 05 '16 at 00:41
  • Which OS version do you use? – ErikEJ Feb 05 '16 at 05:22
  • Microsoft solution still working nowadays (re start VS) – AFetter Sep 20 '16 at 00: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
monoceres
  • 4,722
  • 4
  • 38
  • 63
1

To add a new migration in EF7 use this command :

dnx ef migrations add YourMigrationUniqueName
Chtioui Malek
  • 11,197
  • 1
  • 72
  • 69
0

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

Just use "add-Migration"

ErikEJ
  • 40,951
  • 5
  • 75
  • 115
  • Is this in PowerShell console or the new DNX tools? – user183872 Feb 03 '16 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 Feb 04 '16 at 23:17
  • Powershell doesn't seem to like the command. I've got EntityFramework.Commands installed so not sure whats going on. – user183872 Feb 04 '16 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 Feb 04 '16 at 23:31
0

Currently EF migrations are not supported out of the box:

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

user183872
  • 767
  • 2
  • 6
  • 20
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

Igor Leal
  • 1
  • 1