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

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

问题描述

我正在尝试使用

  • 我已经创建了一个ASP.NET Core Web应用程序
  • 我已使用现在,我正在尝试使用 dotnet ef迁移从项目文件夹(位于project.json所在的位置)中的命令提示符添加Initial 来设置数据库迁移:

    Now, I am trying to setup the database migration using dotnet ef migrations add Initial from command prompt within project's folder (where project.json is located):

    找不到与命令"dotnet-ef"匹配的可执行文件

    No executable found matching command "dotnet-ef"

    我更改了project.json,以便dotnet-ef起作用:

    I have changed project.json, so that dotnet-ef works:

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

    现在,生成失败并显示以下错误:

    Now, the generation fails with the following error:

    指定的框架'Microsoft.NETCore.App'版本找不到'1.0.0-rc2-3002702'.-检查应用程序依赖性并确定安装在以下位置的框架版本:C:\ Program Files \ dotnet \ shared \ Microsoft.NETCore.App-已安装以下版本:1.0.01.0.11.1.0-或者,安装框架版本"1.0.0-rc2-3002702"

    The specified framework 'Microsoft.NETCore.App', version '1.0.0-rc2-3002702' was not found. - Check application dependencies and target a framework version installed at: C:\Program Files\dotnet\shared\Microsoft.NETCore.App - The following versions are installed: 1.0.0 1.0.1 1.1.0 - Alternatively, install the framework version '1.0.0-rc2-3002702'

    好吧,这是有道理的,因为Microsoft.EntityFrameworkCore.Tools 1.0.0-preview1-final依赖于错误中提到的旧版本(如project.lock.json文件中的版本).

    Ok, it makes sense, because Microsoft.EntityFrameworkCore.Tools 1.0.0-preview1-final relies on the old version mentioned in the error, as found in the project.lock.json file.

    我不想降级,所以我放了最新版本的Microsoft.EntityFrameworkCore.Tools:

    I don't want to downgrade, so I put the latest version of Microsoft.EntityFrameworkCore.Tools I could find:

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

    这样做会导致相同的错误:

    Doing this will lead to the same error:

    找不到与命令"dotnet-ef"匹配的可执行文件

    No executable found matching command "dotnet-ef"

    我如何使其在1.1版中工作?

    How can I make it work in version 1.1?

    其他可能有用的上下文信息:

    Other context information that might be useful:

    操作系统:Windows 7 x64VS:2015年社区版来自project.json的其他部分:

    OS: Windows 7 x64 VS: 2015 Community Edition Other parts from project.json:

    "frameworks": {
    "netcoreapp1.1": {
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
    },
    
    "runtimes": {
    "win7-x64": {}
    },
    

    推荐答案

    更新[30/3/2017]

    新软件包为

    Install-Package Microsoft.EntityFrameworkCore.Tools
    


    原始

    <罢工>尝试添加

    "tools": {
        "Microsoft.EntityFrameworkCore.Tools.DotNet": "1.1.0-preview4"
      }
    

    此外,这里是有关使用EF Core 1.1.0设置.Net Core 1.1.0的教程

    Additionally here is a tutorial on setting up .Net Core 1.1.0 with EF Core 1.1.0

    https://docs.microsoft.com/en-us/ef/core/get-started/netcore/new-db-sqlite

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

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