How do I reference Entity Framework 6 from a .NET core class library in RC2?

.net-core .net-core-rc2 entity-framework-6 entity-framework-core

Question

I have a .NET core class library from which I want to reference Entity Framework 6.1.3. Here is my project.json:

{
  "version": "1.0.0-*",

  "dependencies": {
    "NETStandard.Library": "1.5.0-rc2-24027",
    "EntityFramework": "6.1.3" 
  },

  "frameworks": {
    "netstandard1.5": {
      "imports": "dnxcore50"
    }
  }
}

I'm getting this compilation error:

The dependency EntityFramework 6.1.3 does not support framework .NETStandard,Version=v1.5.

So I tried switching the NetStandard.Library dependency to Microsoft.NETCore.App like so:

{
  "version": "1.0.0-*",

  "dependencies": {
    "Microsoft.NETCore.App": {
    "version": "1.0.0-rc2-3002702",
    "type": "platform"
    },
    "EntityFramework": "6.1.3"
  },

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

I'm getting a smilar compilation error as earlier:

The dependency EntityFramework 6.1.3 does not support framework .NETCoreApp,Version=v1.0

Basically, this leaves me with no option to reference Entity Framework 6.1.3 from .NET core.

I can refer EF Core from .NET core class libraries, but it is not something I wish to do right now.

Is there a solution to this?

1
7
5/27/2016 2:05:25 PM

Accepted Answer

Entity Framework 6.1.3 does not support .NET Core. This was part of the motivation for creating Entity Framework Core. EF 6 has deep ties to APIs in .NET Framework that may not be ported to exist in .NET Core.

You can still use EF6 with "project.json" projects but you need to target .NET Framework instead of .NET Core.

{
    "dependencies": {
        "EntityFramework": "6.1.3"
    },
    "frameworks": {
        "net461": { }
    }
}
11
6/4/2016 3:53:51 AM


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