【问题标题】:Cannot run 'dotnet ef' on EF6 after upgrading to .NET Core 1.0 project files升级到 .NET Core 1.0 项目文件后无法在 EF6 上运行“dotnet ef”
【发布时间】:2016-09-08 12:04:58
【问题描述】:

将所有 project.json 文件升级到 .NET 核心的新格式后,我无法为 Entity Framework 6 迁移运行“dotnet ef”。任何人都可以看到下面的 project.json 有什么问题吗?

在我的 project.json 看起来像这样之前:

{
   "frameworks": {
     "dnx46": {
       "dependencies": {
       }
     }
   },
   "dependencies": {
     "EntityFramework": "6.1.3",
     "EntityFramework.DynamicFilters": "1.4.8-*",
     "Migrator.EF6": "1.1.0",
     ....
   },
   "commands": {
     "ef": "Migrator.EF6"
   }
 }

现在看起来像这样:

    {
      ...
      "frameworks": {
        "net46": {
          "dependencies": {
          }
        }
      },
      "dependencies": {
        "EntityFramework": "6.1.3",
        "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0",
        "EntityFramework.DynamicFilters": "1.4.8-*",
        "Migrator.EF6": "1.2.0",
        "Migrator.EF6.Tools": {
          "version": "1.0.3",
          "target": "package",
          "type": "build"
        },
        ...
      },
      "tools": {
        "Migrator.EF6.Tools": {
          "version": "1.0.3",
          "imports": "portable-net45+win8+dnxcore50"
        }
      }
    }

这是我当前运行“dotnet ef”时出现的错误消息:

未处理的异常: Microsoft.DotNet.Cli.Utils.CommandUnknownException:没有可执行文件 找到匹配的命令“dotnet-ef”

【问题讨论】:

    标签: entity-framework .net-core


    【解决方案1】:

    您必须将其添加到您的 project.json 文件中。

    "buildOptions": {
      "emitEntryPoint": true
    }
    

    此外,如果您没有 Main 类,请添加一个空 Main 类,如下所示:

    public class Program
    {
    
        public static void Main(string[] args)
        {
    
        }
    }
    

    【讨论】:

    • 好建议!添加后它抱怨没有主程序存在。所以在添加了一个空的 Main 类之后它就起作用了。非常感谢。
    • 请将您的问题作为一个新问题@ZainAlabdinTawfiq 然后您将获得更好的反馈。
    • 对不起,请忽略,我会删除
    猜你喜欢
    • 2016-10-30
    • 2016-11-02
    • 2018-11-02
    • 2021-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-12-14
    • 1970-01-01
    相关资源
    最近更新 更多