dnx : Error: Unable to load application or execute command 'ef'

asp.net-core dnx entity-framework-core

Question

I am using using ASP.NET 5 Beta 8 with Entity Framework 7 Beta 8

I created a new class Library Package.

I ran the following install packages prompts:

Install-Package EntityFramework.SqlServer -Pre
Install-Package EntityFramework.Commands -Pre
Install-Package Microsoft.AspNet.Identity.EntityFramework -Pre

My project.json

{
 "version": "1.0.0-*",
 "description": "MARS Class Library",
 "authors": [ "myname" ],
  "tags": [ "" ],
  "projectUrl": "",
  "licenseUrl": "",
  "frameworks": {
    "dnx451": { }
  },
  "dependencies": {
     "EntityFramework.Commands": "7.0.0-beta8",
     "EntityFramework.SqlServer": "7.0.0-beta8",
     "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-beta8",
  }
}

In my package manager console I navigate to my src\project directory in which the project.json is located and run any dnx ef command e.g.:

dnx ef migrations --help

or

 dnx ef migrations add InitialMigration

However I get the following error:

dnx : Error: Unable to load application or execute command 'ef'.

At line:1 char:1

  • dnx ef migrations --help

  • ~~~~~~~~~~~~~~~~~~~~~~~~

    • CategoryInfo : NotSpecified: (Error: Unable t...e command 'ef'.:String) [], RemoteException
    • FullyQualifiedErrorId : NativeCommandError

I have a DBContext class and model classes but the error seems to be related to not being able to understand they keyword ef at all.

What am I missing?

Accepted Answer

Solution:

Add the ef command to your project.json

   "commands": {
      "ef": "EntityFramework.Commands"
    }


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Is this KB legal? Yes, learn why