Asp.net Core EF in VS 2015

asp.net-core entity-framework-core

Question

I follow ASP.NET Core - New Database to use EF in Asp.net Core under VS 2015. But got below error after installing the packages.

Startup project 'src\CoreMVCWebAPI' is an ASP.NET Core or .NET Core project for Visual Studio 2015. This version of the Entity Framework Core Package Manager Console Tools doesn't support these types of projects.

In the document, it says, it need VS 2017 RC, I am wondering whether it is available under VS 2015, or is there any workaround that I could use EF in Asp.net Core, or Ado.net to retrive Data from 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%" ]
  }
}

Source Code:https://github.com/Edward-Zhou/DotNetCore

1
3
3/2/2017 12:19:21 PM

Accepted Answer

You cant use MSBuild (Visual Studio 2017) packages in CSproj (Visual Studio 2015) project. If you will change Microsoft.EntityFrameworkCore.Tools version from 1.1.0-msbuild3-final to for example 1.1.0-preview4-final it should work

Also comments were not allowed in project.json to comply strictly with JSON format. See this announcement github.com/aspnet/Announcements/issues/24 and linked issue for more information/discussion.

7
3/6/2017 11:32:58 AM

Popular Answer

You must install an earlier version of EF Core, due to compatibility of .NET Core 2.0 with Visual Studio 2015.

I selected EF Core 1.1.5 version and got the message: "Successfully installed 'Microsoft.EntityFrameworkCore.Tools 1.1.5'"

Greetings, Andres!



Related Questions





Related

Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow