EF Core 1.1 preview1:找不到匹配命令“dotnet-ef”的可執行文件

asp.net entity-framework entity-framework-core macos migration

大家好,我在ASP.NET Core上的項目中遇到了EFCore遷移的問題。一些技術信息:操作系統:macOS

dotnet --version 1.0.0-preview2-003148

這是我的project.json:

{
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Mvc": "1.0.1",
    "Microsoft.AspNetCore.Routing": "1.0.1",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.0.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Configuration.CommandLine": "1.0.0",
    "Microsoft.Extensions.Logging": "1.1.0-preview1-final",
    "Microsoft.Extensions.Logging.Console": "1.1.0-preview1-final",
    "Microsoft.Extensions.Logging.Debug": "1.1.0-preview1-final",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.1.0-preview1-final",
    "Microsoft.Extensions.Logging.Abstractions": "1.1.0-preview1-final",
    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.0.2",
    "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview3-final",
    "Microsoft.EntityFrameworkCore.Design": {
      "type": "build",
      "version": "1.1.0-preview1-final"
    },
    "Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.0.2"
  },
  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.0.0-preview3-final",
      "imports": [
        "portable-net45+win8+dnxcore50",
        "portable-net45+win8"
      ]
    }
  },
  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ],
      "buildOptions": {
        "emitEntryPoint": true
      }
    }
  },
  "buildOptions": {
    "emitEntryPoint": true,
    "preserveCompilationContext": true
  },
  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },
  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings.json",
      "web.config"
    ]
  },
  "scripts": {
    "postpublish": [
      "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%"
    ]
  },
  "tooling": {
    "defaultNamespace": "TTT"
  }
}

我從project.json文件夾中啟動“dotnet ef”命令。

我的行動:

1)dotnet恢復

2)dotnet ef

之後我收到此錯誤:“找不到匹配命令”dotnet-ef“的可執行文件。

我在Program類(Program.cs)中有靜態的“Main”方法。

有誰知道我做錯了什麼?

謝謝。

一般承認的答案

您需要將"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0-preview3-final"到工具部分。

有關詳細信息,請參閱https://blogs.msdn.microsoft.com/dotnet/2016/10/25/announcing-entity-framework-core-1-1-preview-1/


熱門答案

版本1.1.0今天發布,所以在project.json添加的正確版本現在是1.1.0-preview4-final

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


Related

許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow
許可下: CC-BY-SA with attribution
不隸屬於 Stack Overflow