3
votes

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

3
Which tools version do you use? There is currently a change happening with VS 2017 that changes the project format, so the newest tooling versions (newer than preview2) will not work with VS 2015. - poke
Use this link. This demonstrates how to create ASP.NET Core 1.0 MVC web applications using Entity Framework Core 1.0 and Visual Studio 2015. - Sanket

3 Answers

7
votes

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.

0
votes

You need a reference to EntityFrameWorkCore.Tools.DotNet in the Tools Section as below

"Microsoft.EntityFrameworkCore.Tools.DotNet": "1.0.0"

For more info, look at my answer here.

The term "Add-Migration" is not recognized

0
votes

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!