VS 2015中的Asp.net Core EF

asp.net-core entity-framework-core

我遵循ASP.NET核心 - 新數據庫在VS 2015下使用Asp.net Core中的EF。但是在安裝軟件包後出現以下錯誤。

啟動項目'src \ CoreMVCWebAPI'是Visual Studio 2015的ASP.NET核心或.NET核心項目。此版本的Entity Framework核心軟件包管理器控制台工具不支持這些類型的項目。

在文檔中,它說,它需要VS 2017 RC,我想知道它是否在VS 2015下可用,或者是否有任何解決方法我可以在Asp.net Core或Ado.net中使用EF從SQL DataBase中檢索數據。

PM> Add-Migration MyFirstMigration
Invalid object passed in, ':' or '}' expected. (339): {
  "dependencies": {
    "Microsoft.NETCore.App": {
      "version": "1.0.1",
      "type": "platform"
    },
    "Microsoft.AspNetCore.Diagnostics": "1.0.0",
    "Microsoft.AspNetCore.Server.IISIntegration": "1.0.0",
    "Microsoft.AspNetCore.Server.Kestrel": "1.0.1",
    "Microsoft.Extensions.Logging.Console": "1.0.0",
    //Dependence for MVC
    "Microsoft.AspNetCore.Mvc": "1.1.1",
    "Microsoft.AspNetCore.StaticFiles": "1.1.0",
    "Microsoft.Extensions.Configuration.FileExtensions": "1.1.0",
    "Microsoft.Extensions.Configuration.Json": "1.1.0",
    //Dependence for EF
    "Microsoft.EntityFrameworkCore":"1.1.0",
    "Microsoft.EntityFrameworkCore.InMemory": "1.1.0",
    "Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    "Microsoft.EntityFrameworkCore.Tools":"1.1.0-preview4-final"
    //Dependence for EF with SQL, this is avalible under VS 2017 RC
    //"Microsoft.EntityFrameworkCore.SqlServer": "1.1.0",
    //Entity Framework commands to maintain the database
    //"Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview4-final"
  },

  "tools": {
    "Microsoft.AspNetCore.Server.IISIntegration.Tools": "1.0.0-preview2-final"
  },

  "frameworks": {
    "netcoreapp1.0": {
      "imports": [
        "dotnet5.6",
        "portable-net45+win8"
      ]
    }
  },

  "buildOptions": {
    "emitEntryPoint": true,
    //used for Razor pages which are compiled at runtime,and the compiler needs access to reference assemblies,
    //to make sure it compiles correctly
    "preserveCompilationContext": true
  },

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

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

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

源代碼: https//github.com/Edward-Zhou/DotNetCore

一般承認的答案

您無法在CSproj (Visual Studio 2015)項目中使用MSBuild (Visual Studio 2017)包。如果你將Microsoft.EntityFrameworkCore.Tools版本從1.1.0-msbuild3-final更改為例如1.1.0-preview4-final它應該工作

project.json中也不允許註釋嚴格遵守JSON格式。有關更多信息/討論,請參閱此公告github.com/aspnet/Announcements/issues/24和鏈接問題。


熱門答案

由於.NET Core 2.0與Visual Studio 2015的兼容性,您必須安裝早期版本的EF Core。

我選擇了EF Core 1.1.5版本並收到消息:“已成功安裝'Microsoft.EntityFrameworkCore.Tools 1.1.5'”

問候,安德烈斯!



Related

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