mrahhal/Migrator.EF6

Unhandled Exception: Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-ef"

Closed this issue · 6 comments

Merry Christmas,

I am trying to create migrations and all I get is this error: Unhandled Exception: Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-ef" and powershell crashes.
For context, my project is based on net461, dotnet is v1.1 and all packages are 1.1.0 or 1.1.0-preview-4 as the case may be. MR.AspNet.Identity.EntityFramework6.Key.Int and latest Migrator.EF6 v 1.0.8 is installed. dunno if you can help. Below is the complete stack trace:

Unhandled Exception: Microsoft.DotNet.Cli.Utils.CommandUnknownException: No executable found matching command "dotnet-ef" at     Microsoft.DotNet.Cli.Utils.ProjectDependenciesCommandFactory.FindProjectDependencyCommands(Stri    ng commandName, IEnumerable`1 commandArgs, String configuration, NuGetFramework framework,     String outputPath, String buildBasePath, String projectDirectory)
       at Microsoft.DotNet.Cli.Utils.ProjectDependenciesCommandFactory.Create(String commandName,     IEnumerable`1 args, NuGetFramework framework, String configuration)
       at Microsoft.Extensions.Internal.DotnetToolDispatcher.CreateDispatchCommand(IEnumerable`1     dispatchArgs, NuGetFramework framework, String configuration, String outputPath, String     buildBasePath, String projectDirectory, String toolName)
       at Microsoft.Extensions.Internal.DotnetToolDispatcher.CreateDispatchCommand(IEnumerable`1     dispatchArgs, NuGetFramework framework, String configuration, String outputPath, String     buildBasePath, String projectDirectory)
       at Migrator.EF6.Tools.Program.Dispatch(String[] args)
       at Migrator.EF6.Tools.Program.Main(String[] args)

Merry Christmas,

First things first, make sure you included an entry in the "tools" section in project.json. Refer to the README to see the whole step. If this isn't the problem, post your project.json.

Here is my project.json:

{
  "userSecretsId": "aspnet-SwiftSchool-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx",

  "dependencies": {
    "AutoMapper": "5.2.0",
    "AutoMapper.EF6": "0.5.0",
    "AutoMapper.Extensions.Microsoft.DependencyInjection": "1.1.2",
    "EntityFramework": "6.1.3",
    "EntityFramework6.Npgsql": "3.1.1",
    "MediatR.Extensions.Microsoft.DependencyInjection": "1.0.1",
    "Microsoft.AspNetCore.Authentication.Cookies": "1.1.0",
    "Microsoft.AspNetCore.Diagnostics": "1.1.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Razor.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    "Microsoft.Extensions.Configuration.UserSecrets": "1.1.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.1.0",
    "Microsoft.Extensions.Logging.Debug": "1.1.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.1.0",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.1.0",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "Microsoft.VisualStudio.Web.CodeGenerators.Mvc": {
      "version": "1.1.0-preview4-final",
      "type": "build"
    },
    "MR.AspNet.Identity.EntityFramework6.Key.Int": "*",
    "Npgsql": "3.1.9"
  },
  "Migrator.EF6.Tools": {
    "version": "1.0.8",
    "target": "package",
    "type": "build"
  },

  "tools": {
    "BundlerMinifier.Core": "2.2.306",
    "Microsoft.AspNetCore.Razor.Tools": "1.1.0-preview4-final",
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.1.0-preview4-final",
    "Microsoft.Extensions.SecretManager.Tools": "1.1.0-preview4-final",
    "Microsoft.VisualStudio.Web.CodeGeneration.Tools": {
      "version": "1.1.0-preview4-final",
      "imports": [
        "portable-net45+win8"
      ]
    },
    "Migrator.EF6.Tools": {
      "version": "1.0.8",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "net461": {}
  },

  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "prepublish": [ "bower install", "dotnet bundle" ],
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

I did the install exactly as mentioned in the read me only I believe that mistakes can happen so I will triple check everything again even though I have posted this.

I feel like this part:

"Migrator.EF6.Tools": {
    "version": "1.0.8",
    "target": "package",
    "type": "build"
  },

is outside the "dependencies" section.

And you don't need the "target": "package" line but it shouldn't matter.

(And just a note, you should use 3 backticks in markdown to render multiline prestructured text properly. I edited your comment)

Ok sir, thanks for the edit. I will check my project.json again and make sure of everything then let you know what I find and how I fare.

Just tried it and I have to say you are right. I think maybe I was up too long so I didn't even notice that was the case.

Thanks a billion mate

No worries. Glad it worked for you.