1
votes

I'm using dotnet ef migrations add [abc] command add migration but it gives following error: No executable found matching command "dotnet-ef"

I have tried from command prompt as well as package manager console but gives same error. I have checked the path as well, i'm running command where my project.json sits.

Microsoft.EntityFrameworkCore.SqlServer is already installed.

project.json code is as follows:

{
  "version": "1.0.0-*",
  "dependencies": {
    "Bloomerang.Domain": "1.0.0-*",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.0.1"
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },
  "Microsoft.EntityFrameworkCore.Tools": {
    "version": "1.0.0-preview1-final",
    "imports": [
      "portable-net45+win8+dnxcore50",
      "portable-net45+win8"
    ]
  }
}
1
The command is dotnet ef migrations add {MigrationName} (without hyphen) and not dotnet-ef. See here for a tutorial: benjii.me/2016/05/dotnet-ef-migrations-for-asp-net-coreDirk Vollmar

1 Answers

2
votes

If you need to use .NET Core CLI commands then your project.json should include the below items. Specially the Microsoft.EntityFrameworkCore.Design package.I cannot see it on your file.So you need to install it before use those commands.

project.json

{
    "dependencies": {
        "Microsoft.EntityFrameworkCore.Design": {
            "type": "build",
            "version": "1.0.0-preview2-final"
        }
    },

    "tools": {
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview2-final"
    },

    "frameworks": {
        "netcoreapp1.0": { }
    }
}