Attempting to install EF Core by targeting a portable .Net 4.6.1 class library

This is my first experiment with the EF Core, ASP Net Core, and Portable Class libraries with VS2015. It’s fair to say that I'm upset.

I want to create a library where I can set EntityFramework.Core. This library must be used in the WPF application and in the ASP NET Core web application, while ignoring any good concepts of layered applications. My thought was to create a portable class library.

Using a project template where I am targeting .NET 4.6 and ASP Net Core ...

Goals

I get a project with class and project.json file as follows:

{ "supports": { "net46.app": {}, "dnxcore50.app": {} }, "dependencies": { "Microsoft.NETCore": "5.0.0", "Microsoft.NETCore.Portable.Compatibility": "1.0.0" }, "frameworks": { "dotnet": { "imports": "portable-net452" } } } 

Now when I install the EntityFramework.Core package from nuget ...

Install EF Core Nuget

... I get the following output:

 Restoring packages for 'Acme.PCLEFClassLib'. Restoring packages for K:\TFS\TestApps\Projects\DotNetCore\Acme.PCL1\Acme.PCL1\project.json... Detected package downgrade: System.Reflection from 4.1.0-beta-23225 to 4.0.10 Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> Microsoft.Extensions.DependencyInjection.Abstractions (>= 1.0.0-rc1-final) -> System.Reflection (>= 4.1.0-beta-23225) Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> System.Reflection (>= 4.0.10) Detected package downgrade: System.Reflection from 4.1.0-beta-23225 to 4.0.10 Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> Microsoft.Extensions.Logging.Abstractions (>= 1.0.0-rc1-final) -> System.Reflection (>= 4.1.0-beta-23225) Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> System.Reflection (>= 4.0.10) Version conflict detected for System.Collections. Acme.PCLEFClassLib (>= 1.0.0) -> EntityFramework.Core (>= 7.0.0-rc1-final) -> System.Collections (>= 4.0.11-beta-23516) Acme.PCLEFClassLib (>= 1.0.0) -> Microsoft.NETCore.Portable.Compatibility (>= 1.0.0) -> Microsoft.NETCore.Runtime (>= 1.0.0) -> Microsoft.NETCore.Runtime.CoreCLR-x86 (>= 1.0.0) -> System.Collections (= 4.0.10). EntityFramework.Core 7.0.0-rc1-final is not compatible with .NETPlatform,Version=v5.0. Some packages are not compatible with .NETPlatform,Version=v5.0. Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0. Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0. Some packages are not compatible with DNXCore,Version=v5.0. Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0 (win7-x86). Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0 (win7-x86). Some packages are not compatible with DNXCore,Version=v5.0 (win7-x86). Ix-Async 1.2.5 is not compatible with DNXCore,Version=v5.0 (win7-x64). Remotion.Linq 2.0.1 is not compatible with DNXCore,Version=v5.0 (win7-x64). Some packages are not compatible with DNXCore,Version=v5.0 (win7-x64). Package restore failed for 'Acme.PCLEFClassLib'. Package restore failed. Rolling back package changes for 'Acme.PCLEFClassLib'. ========== Finished ========== 

Is it possible to install EF Core in a portable class library? If so, how - what do I need to do with the project?

I just feel like I'm going to look around for solutions on the line.

UPDATE 1

Tried installing EntityFramework.MicrosoftSqlServer in my PCL.

Given that EntityFramework.MicrosoftSqlServer is installed when you create a standard ASP Net Core project that uses the dnxcore50 structure. Why, if I do this in the PCL, complains that:

 EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final is not compatible with .NETPlatform,Version=v5.0. 

If so, how is it installed in an ASP NET Core project.

UPDATE 2

I created new PCL targeting .NET 4.5.1. Then I installed EntityFramework.MicrosoftSqlServer 7.0.0-rc1-final into it via Nuget and did not install any problems. Although I can’t repeat it now. I just created a standalone solution with a PCL library project focused on ASP NET Core and .NET 4.5.1. Now you get the following:

 Attempting to gather dependency information for package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' with respect to project 'AnotherPCLEFFUP', targeting '.NETPortable,Version=v4.5,Profile=Profile75' Attempting to resolve dependencies for package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' with DependencyBehavior 'Lowest' Resolving actions to install package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' Resolved actions to install package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' Install failed. Rolling back... Package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' does not exist in project 'AnotherPCLEFFUP' Package 'EntityFramework.MicrosoftSqlServer.7.0.0-rc1-final' does not exist in folder 'K:\TFS\TestApps\Projects\DotNetCore\AnotherPCLEFFUP\packages' Invalid portable frameworks. 

The same thing happens with the installation of EntityFramework.Core.7.0.0-rc1-final.

It is fair to say that it is completely frustrating. Maybe I'm barking the wrong tree or just barking crazy today.

+5
source share
3 answers

I do not know how this will work for your portable class needs, but for regular .NET (4.6 or so on) I found the following. (see rant below)

So I don’t know if it is kosher or not, but this source is working right now:

Add nuget package source (Options - Package Sources - Add (Plus)

If you install for SqlServer, just install this:

Microsoft.EntityFrameworkCore.SqlServer

Or select another top-level dependency that picks up the rest.

* [start-recitation] This was only through discussion in discussions on EF github. It is completely unforgivable that they do not have a practical description explaining what to do right now. They have to pull out the version of “RC” 1 with all its errors and its radical design from what they are working on now and which have not been updated for more than 5 months (! And this is with the “pre” -release 'mark checked!), Completely from nuget.

Let me add: I like everything these guys do, I like new bits, a lot of really good things. But we shouldn't be left hanging for half a year with the supposedly and still flagged “RC” release when it is full of bugs that are already fixed in a radically redesigned version of rc2 that they haven't published. [/ End recitation] *

+2
source

You tried to change the import of frameworks to:

 "frameworks": { "netcoreapp1.0": { "imports": "portable-net451+win8" } } 
0
source

I am creating a Class Library Core 4.6 project and using this code in project.json

  { "dependencies": { "Microsoft.EntityFrameworkCore.SqlServer": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.SqlServer.Design": "1.0.0-rc2-final", "Microsoft.EntityFrameworkCore.Tools": "1.0.0-preview1-final", "Microsoft.NETCore.App": { "version": "1.0.0-rc2-3002702", "type": "platform" } }, "tools": { "Microsoft.AspNetCore.Server.IISIntegration.Tools": { "version": "1.0.0-preview1-final", "imports": "portable-net45+win8+dnxcore50" }, "Microsoft.EntityFrameworkCore.Tools": { "version": "1.0.0-preview1-final", "imports": [ "portable-net45+win8+dnxcore50", "portable-net45+win8" ] } }, "frameworks": { "netcoreapp1.0": { "imports": [ "dotnet5.6", "dnxcore50", "portable-net45+win8" ] } } } 
0
source

All Articles