实体框架核心RC2 dotnet ef无法用于此操作系统平台

时间:2016-06-08 14:42:07

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

我有一个ASP.Net Core项目,我一直在尝试使用现有数据库来创建dbcontext。这是project.json文件:

{
      "dependencies": {
        "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.EntityFrameworkCore": "1.0.0-rc2-final",
        "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final",
        "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final",
        "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-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"
      },

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

      "frameworks": {
        "net452": { }
      },

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

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

      "scripts": {
        "postpublish": [ "dotnet publish-iis --publish-folder %publish:OutputPath% --framework %publish:FullTargetFramework%" ]
      }
    }

Microsoft.EntityFrameworkCore.Tools是" preview1 final",但是我没有看到任何更新的版本,比如rc2,我可以使用...我在安装之前安装了各种不同的依赖项当前状态,但我已经执行了dotnet工具来重建整个项目,甚至使用了一些答案中提到的神秘的--infer-runtimes选项。仍然没有运气。

我在机器上安装了PowerShell 5.0:

PS C:\projectfolder> $PSVersionTable.PSVersion

Major  Minor  Build  Revision
-----  -----  -----  --------
5      0      10586  117

在PowerShell中运行dotnet ef命令时,在项目文件夹中,我收到以下错误(我用&#34替换了项目名称和路径;项目文件夹"这里)。如果我使用"脚手架" ef命令,所以这里只是获取错误的最简单的命令行形式:

PS C:\projectfolder> dotnet --verbose ef --help    
[...]
    Running C:\projectfolder\bin\Debug\net452\win7-x86\Microsoft.EntityFrameworkCore.Tools.Cli.exe --framework net452 --configuration Debug --verbose --help --dispatcher-version 1.0.0-preview1-20901
    System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.
       at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
       at System.Diagnostics.Process.Start()
       at Microsoft.DotNet.Cli.Utils.Command.Execute()
       at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
       at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
       at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)

dotnet --info返回:

.NET Command Line Tools (1.0.0-preview1-002702)

Product Information:
 Version:     1.0.0-preview1-002702
 Commit Sha:  6cde21225e

Runtime Environment:
 OS Name:     Windows
 OS Version:  6.1.7601
 OS Platform: Windows
 RID:         win7-x86

系统是win7 32bit。此系统上安装的.Net框架是:

  • 核心1.0.0 RC2 - SDK预览1(x86)
  • 核心1.0.0 RC2 - VS 2015工具 预览1
  • 4.5,4.5.1,4.5.2,4.6,4.6.1

更新:我还(再次)检查了它是否可以从VS Package Manager的命令行运行,但是(正如我所料)它失败并显示相同的错误消息:< / p>

PM> Scaffold-DbContext -Connection 'Server=name;Database=testdb;Persist Security Info=False;User ID=user;Password=pass' -Provider Microsoft.EntityFrameworkCore.SqlServer -Verbose
Working directory: C:\projectfolder
Executing command: dotnet ef --configuration Debug --build-base-path .\bin\ dbcontext scaffold 'Server=name;Database=testdb;Persist Security Info=False;User ID=user;Password=pass' Microsoft.EntityFrameworkCore.SqlServer --verbose
System.ComponentModel.Win32Exception: The specified executable is not a valid application for this OS platform.    at System.Diagnostics.Process.StartCore(ProcessStartInfo startInfo)
   at System.Diagnostics.Process.Start()
    at Microsoft.DotNet.Cli.Utils.Command.Execute() 
   at Microsoft.EntityFrameworkCore.Tools.DispatchCommand.<>c__DisplayClass2_0.<Create>b__0()
   at Microsoft.Extensions.CommandLineUtils.CommandLineApplication.Execute(String[] args)
   at Microsoft.EntityFrameworkCore.Tools.Program.Main(String[] args)
 The specified executable is not a valid application for this OS platform.

更新:我添加了&#34; Microsoft.EntityFrameworkCore&#34;项目依赖项,但没有区别。 (我猜这个集会已经存在,作为其他人的依赖......)

我做错了什么?* 帮助......还有什么我应该安装/检查的吗?

0 个答案:

没有答案
相关问题