entity-framework – 未找到可执行文件匹配命令“dotnet-ef”

前端之家收集整理的这篇文章主要介绍了entity-framework – 未找到可执行文件匹配命令“dotnet-ef”前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在做一个项目示例使用ASP.Net核心RC2与Microsoft.EntityFramework.Core和sqlite。

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

但是,当我运行这个命令:

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

解决方法

您应该只需要更新project.json文件的工具部分,包括
"Microsoft.EntityFrameworkCore.Tools": {
  "version": "1.0.0-preview1-final","imports": [
    "portable-net45+win8+dnxcore50","portable-net45+win8"
  ]
}

这应该使dotnet ef命令可用。

重要

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

实体框架核心1.1
如果您在升级到Entity Framework Core 1.1后再次遇到此问题,请务必使用Microsoft.EntityFrameworkCore.Tools.DotNet版本1.1.0-preview4替换Microsoft.EntityFrameworkCore.Tools依赖项。也不需要保留导入部分。有关此的详细信息,请参阅Entity Framework Core 1.1 release announcement blog post下的“升级到1.1”标题

原文链接:https://www.f2er.com/aspnet/254247.html

猜你在找的asp.Net相关文章