找不到与命令“dotnet-ef"匹配的可执行文件 [英] No executable found matching command "dotnet-ef"

查看:27
本文介绍了找不到与命令“dotnet-ef"匹配的可执行文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用带有 Microsoft.EntityFramework.Core 和 SQLite 的 ASP.Net Core RC2 来做一个项目示例.

I'm doing a project sample by using ASP.Net Core RC2 with Microsoft.EntityFramework.Core and SQLite.

我遵循了本教程:https://damienbod.com/2015/08/30/asp-net-5-with-sqlite-and-entity-framework-7/

但是,当我运行此命令时:

But, when I run this command :

dotnet ef migrations add FirstMigration

我收到此错误:

No executable found matching command "dotnet-ef"

这是我的 project.json 配置:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.0-rc2-3002702",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0-rc2-final",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0-rc2-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc2-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore": "1.0.0-rc2-final",
    "Microsoft.EntityFrameworkCore.Sqlite": "1.0.0-rc2-final"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": {
      "version": "1.0.0-preview1-final",
      "imports": "portable-net45+win8+dnxcore50"
    }
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "dnxcore50",
        "portable-net45+win8"
      ]
    }
  },

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

  "runtimeOptions": {
    "gcServer": true
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "Views",
      "appsettings.json",
      "web.config"
    ]
  },

  "scripts": {
    "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
  }
}

推荐答案

Entity Framework Core 1.0

您应该只需要更新 project.json 文件的 tools 部分以包含以下内容:

You should just need to update the tools section of your project.json file to include this:

"Microsoft.EntityFrameworkCore.Tools": {
  "version": "1.0.0-preview1-final",
  "imports": [
    "portable-net45+win8+dnxcore50",
    "portable-net45+win8"
  ]
}

这应该使 dotnet ef 命令可用.

This should make the dotnet ef commands available.

重要

我还应该注意,dotnet ef 命令仅在从包含 project.json 文件的同一目录中运行它们时才可用.

I should also note here that the dotnet ef commands will only be available when running them from the same directory which contains the project.json file.

实体框架核心 1.1
如果您在升级到 Entity Framework Core 1.1 后再次遇到此问题,请务必将 Microsoft.EntityFrameworkCore.Tools 依赖项替换为 Microsoft.EntityFrameworkCore.Tools.DotNet 版本 <代码>1.1.0-preview4.也不需要保留 imports 部分.有关这方面的更多信息,请参阅 Entity Framework Core 1.1 发布公告博文.

Entity Framework Core 1.1
If you are having this problem again after upgrading to Entity Framework Core 1.1, be sure to replace the Microsoft.EntityFrameworkCore.Tools dependency with Microsoft.EntityFrameworkCore.Tools.DotNet version 1.1.0-preview4. There is no need to keep the imports section, either. For more information on this, see the "Upgrading to 1.1" heading under the Entity Framework Core 1.1 release announcement blog post.

这篇关于找不到与命令“dotnet-ef"匹配的可执行文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆