dotnet ef不适用于ef工具1.1.0-preview4-final

时间:2017-01-31 14:40:17

标签: c# entity-framework .net-core entity-framework-core

我在dotnet核心应用程序中使用EF Core。在我的project.json我有下一个配置:

{
  "version": "0.0.0.1",
  "dependencies": {
    "Autofac.Extensions.DependencyInjection": "4.0.0",
    "AutotestConsolidationServer.Database": "1.0.0-*",
    "Microsoft.ApplicationInsights.AspNetCore": "1.0.0",
    "Microsoft.AspNetCore.Mvc": "1.1.0",
    "Microsoft.AspNetCore.Routing": "1.1.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.1.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.1.0",
    "Microsoft.AspNetCore.StaticFiles": "1.0.0",
    "Microsoft.EntityFrameworkCore": "1.1.0",
    "Microsoft.EntityFrameworkCore.Design": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools": {
      "version": "1.1.0-preview4-final",
      "include": "all"
    },
    "Microsoft.EntityFrameworkCore.Tools.DotNet": {
      "version": "1.1.0-preview4-final",
      "include": "all"
    },
    "Microsoft.Extensions.Configuration.EnvironmentVariables": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.0.0",
    "Microsoft.Extensions.Configuration.Json": "1.0.0",
    "Microsoft.Extensions.Logging": "1.1.0",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    "Microsoft.Extensions.Logging.Debug": "1.0.0",
    "Microsoft.Extensions.Options.ConfigurationExtensions": "1.0.0",
    "Microsoft.NETCore.App": {
      "version": "1.1.0",
      "type": "platform"
    },
    "Npgsql.EntityFrameworkCore.PostgreSQL": "1.1.0",
    "Npgsql.EntityFrameworkCore.PostgreSQL.Design": "1.1.0"
  },

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

  "frameworks": {
    "netcoreapp1.6": {
      "imports": [
        "dnxcore50"
      ]
    }
  },

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

  "runtimes": {
    "win10-x64": {},
    "ubuntu.16.10-x64": {}
  },

  "runtimeOptions": {
    "configProperties": {
      "System.GC.Server": true
    }
  },

  "publishOptions": {
    "include": [
      "wwwroot",
      "**/*.cshtml",
      "appsettings*.json",
      "databaseconfig*.json",
      "web.config",
      "run.sh"
    ]
  }
}

但在输出文件夹中发布后,没有任何名为ef.dll的文件,当然命令dotnet ef返回No executable found matching command "dotnet-ef"。我的错在哪里?

更新:@ kloarubeek提示dotnet-ef.dll出现在发布目录中,但命令dotnet ef仍无效。

1 个答案:

答案 0 :(得分:1)

您可以在工具部分中引用它。如果要发布它,请将其移至依赖项

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

发布此文件将导致输出文件夹中出现dotnet-ef.dll。