14
votes

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?

6

6 Answers

26
votes

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

6
votes

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

5
votes

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
votes

To add a new migration in EF7 use this command :

dnx ef migrations add YourMigrationUniqueName
0
votes

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

Just use "add-Migration"

0
votes

Currently EF migrations are not supported out of the box:

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