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

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

问题描述

我正在使用ASP.Net Core RC2与 Microsoft.EntityFramework.Core 和SQLite。



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



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

  dotnet ef migrations添加FirstMigration 

我收到这个错误:

 code>找不到可执行文件匹配命令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
},

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

框架 :{
netcoreapp1.0:{
imported:[
dotnet5.6,
dnxcore50,
portabl e-net45 + win8
]
}
},

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

runtimeOptions:{
gcServer:true
},

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

脚本:{
postpublish:[dotnet publish-iis --publish-folder%publish:OutputPath%--framework%publish:FullTargetFramework %]
}
}


解决方案

p>您只需要更新project.json文件的工具部分即可:

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

这应该使 dotnet ef 命令可用。



重要 / p>

我还应该注意, dotnet ef 命令只有在从同一目录运行时才可用, project.json文件。



实体框架Core 1.1

如果在升级到实体后再次出现此问题Framework Core 1.1,请确保使用 Microsoft.EntityFrameworkCore.Tools.DotNet 版本替换 Microsoft.EntityFrameworkCore.Tools 依赖关系 1.1.0-preview4 。也不需要保留 import 段。有关更多信息,请参阅 Entity Framework Core 1.1发布公告博文


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

I've followed this tutorial: 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

I got this error :

No executable found matching command "dotnet-ef"

Here is my project.json configuration:

{
  "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%" ]
  }
}

解决方案

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"
  ]
}

This should make the dotnet ef commands available.

Important

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.

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天全站免登陆