Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 418
SirG Avatar asked May 27 '16 14:05

SirG


1 Answers

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": { }
    }
}
like image 126
natemcmaster Avatar answered Oct 19 '22 18:10

natemcmaster