1

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

5
  • What version of EF are you installing? And do you want to target the full .NET Framework, or .NET Core or both? Commented Mar 14, 2016 at 16:03
  • @mason I am installing EF 6.1.3. I need EF only for this tutorial but I want to use ASP.NET 5 Web API template instead. Commented Mar 14, 2016 at 16:09
  • share your project.json please Commented Mar 14, 2016 at 16:14
  • 1
    EF 6 doesn't run on .NET Core. That's what EF 7 is for. So either don't build for .NET Core or switch to EF 7. Commented Mar 14, 2016 at 16:17
  • @aguafrommars Per your request, I've just added project.json file code Commented Mar 14, 2016 at 16:19

1 Answer 1

3

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

Sign up to request clarification or add additional context in comments.

1 Comment

Per your suggestion, I removed "dnxcore50": { } from project.json and was able to use EF6.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.