1

In my VS2015 ASP.NET 5 Web API project I installed EF6.1.3 but the enable-migrations command in Package Manage console gives me following error: The term 'enable-migrations' is not recognized as the name of a cmdlet, function, script file, or operable program. None of the suggestions here work for me - giving me still the same error

UPDATE

So far, I've tried the following commands and have closed/re-open the VS (even as administrator):

Install-Package EntityFramework -IncludePrerelease

Update-Package –reinstall EntityFramework

Install-Package EntityFramework.Commands -Pre

Community
  • 1
  • 1
nam
  • 21,967
  • 37
  • 158
  • 332
  • In Package Manage Console have you selected proper default project ? This with EF. – BWA Mar 14 '16 at 18:38
  • @BWA Yes. There is only one project and it's selected. – nam Mar 14 '16 at 18:59
  • 1
    Believe it or not, I bet the answer is close all instances of VS and re-open. – Steve Kennedy Mar 14 '16 at 19:00
  • @SteveKennedy it often helps with problems with VS :-) – BWA Mar 14 '16 at 19:02
  • @SteveKennedy I tried uninstalling/re-installing EF6.1.3, closing/re-opening the VS. Re-opening VS as Administrator. But still the same error. There is only one instance of VS on my desktop (Win7). – nam Mar 14 '16 at 19:24
  • What about using CLEAN (right click on Solution node in Solution Explorer, and click Clean). Then exit VS. Then open it and try again. – Steve Kennedy Mar 14 '16 at 19:26
  • @SteveKennedy I just tired your suggestion but still the same error. I've added an `UPDATE` section to my post. – nam Mar 14 '16 at 19:33

3 Answers3

0

Have you tried the following:

Install-Package EntityFramework -IncludePrerelease

I had the same issue recently.

JYA
  • 100
  • 6
  • I just added an `UPDATE` section in my original post describing what I've tried so far. – nam Mar 14 '16 at 19:32
0

EntityFramework.Commands is designed for EF7 and is not compatible with EF6. It's no wonder 'enable-migrations' is missing because this is not a command in EF7.

You can also try manually adding the EF module. All nuget does to import the commands is execute a small powershell file. You can do this yourself by manually finding and importing EntityFramework.psd1. See https://entityframework.codeplex.com/SourceControl/latest#src/NuGet/EntityFramework/tools/init.ps1

Import-Module C:\MySolution\packages\EntityFramework.6.1.3\tools\EntityFramework.psd1

In theory NuGet should do this automagically anytime it opens, but with ASP.NET 5 tooling, the project model has changed and their may be nuget bugs in VS. Have you upgraded to the latest nuget tooling (v3.3.0)? https://dist.nuget.org/index.html

natemcmaster
  • 25,673
  • 6
  • 78
  • 100
0

I used the solution from this answer

You need to uninstall and then install the EntityFramework again. Just in case the uninstall failed because the EntityFramework used by other package as dependency, use command below to force the uninstall process.

Uninstall-Package -f EntityFramework

Community
  • 1
  • 1
sigeje
  • 328
  • 3
  • 8