IEnumerable <> defined in an assembly that is not referenced - new NuGet class library project

I am using the VS2015 community, I have installed .NET 4.6.01040, and I followed these instructions to install ASP.NET 5.

I want to start moving the site from MVC5 to MVC6 to all the other updates that were with it, so I started with the Entity class library project, which contains my data model. This is what my project.json file looks like:

 { "version": "1.0.0-*", "description": "test.Entities Class Library", "authors": [ "me" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "frameworks": { "net461": { "dependencies": { "System.Runtime": "4.0.0.0" } }, "dotnet5.4": { "dependencies": { "Microsoft.CSharp": "4.0.1-beta-23516", "System.Runtime": "4.0.21-beta-23516", "System.Linq": "4.0.1-beta-23516" "System.Collections": "4.0.11-beta-23516", "System.Threading": "4.0.11-beta-23516" } } }, "dependencies": { "EntityFramework.Core": "7.0.0-rc1-final", } } 

I changed the frame type from "net451" to "net461" because I thought it was a problem and I also tried adding a link to the dependencies, but no luck ...

The error is here:

 [NotMapped] public decimal TotalOrders => Math.Round(Orders.Where(x => x.Code.StartsWith("5") .Sum(x => x.Amount),MidpointRounding.AwayFromZero); 

Full error:

 CS0012 The type 'IEnumerable<>' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Runtime, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. test.Entity..NET Framework 4.6 

Any idea on how to make this work with new types of projects?

+5
source share
2 answers

Because it was not clear to me, from the answer what is needed, I will provide it here.

 { "version": "1.0.0-*", "description": "test.Entities Class Library", "authors": [ "me" ], "tags": [ "" ], "projectUrl": "", "licenseUrl": "", "frameworks": { "net461": { "dependencies": { "System.Runtime": "4.0.0.0" }, "frameworkAssemblies": { "System.Runtime": "4.0.10.0" } }, "dotnet5.4": { "dependencies": { "Microsoft.CSharp": "4.0.1-beta-23516", "System.Runtime": "4.0.21-beta-23516", "System.Linq": "4.0.1-beta-23516" "System.Collections": "4.0.11-beta-23516", "System.Threading": "4.0.11-beta-23516" } } }, "dependencies": { "EntityFramework.Core": "7.0.0-rc1-final", } } 
+7
source

net461 target structure name (TFM) is the complete .NET Framework, and if you want to reference System.Runtime from this structure, you need to move the entry "System.Runtime": "4.0.0.0" to the frameworkAssemblies node.

+6
source

Source: https://habr.com/ru/post/1236329/


All Articles