nam
nam

Reputation: 23749

ASP.NET 5 Web API project template does not allow using Entity Framework

Using VS2015 Enterprise Edition, I created a web app using ASP.NET 5 Web API template as shown below. But when I try to install Entity Framework, it shows the EntityFramework under the References\DNX Core 5.0 folder (as shown in figure 2 here) with an error icon stating the DNX Core 5.0 does not support EF. But when I uninstall EF from this folder, it removes it from the References\DNX 4.5.1 folder, as well. Question: How can I use EF in an ASP.NET 5 Web API project?

project.json file:

{
  "version": "1.0.0-*",
  "compilationOptions": {
    "emitEntryPoint": true
  },

  "dependencies": {
    "Microsoft.ApplicationInsights.AspNet": "1.0.0-rc1",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.FileProviderExtensions": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final"
  },

  "commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
  },

  "frameworks": {
    "dnx451": { },
    "dnxcore50": { }
  },

  "exclude": [
    "wwwroot",
    "node_modules"
  ],
  "publishExclude": [
    "**.user",
    "**.vspscc"
  ]
}

enter image description here

Upvotes: 1

Views: 564

Answers (1)

agua from mars
agua from mars

Reputation: 17404

EF 6 is not compatible with .Net core. Either, remove "dnxcore50": { } from your supported framework in your project.json
For more information using EF 6 with ASP.NET Core visit : Getting Started with ASP.NET 5 and Entity Framework 6

Or use EF 7 : Visit Getting Started on ASP.NET 5

Upvotes: 3

Related Questions