IEnumerable 在未引用的程序集中定义 – 新的NuGet类库项目

我正在使用VS2015社区,我安装了.NET 4.6.01040,并按照这些说明安装了ASP.NET 5。

我想开始将一个站点从MVC5迁移到MVC6所带来的所有其他更新,所以我开始使用包含我的Data模型的Entity Class库项目。 这是我的project.json文件的样子:

 { "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", } } 

我将框架类型从"net451"更改为"net461"因为我认为那是问题,我也尝试添加对依赖项的引用,但没有运气……

错误发生在这里:

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

完整的错误是:

 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 

有关如何使用新项目类型的任何想法?

因为我不清楚答案需要什么,我会在这里提供….

 { "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", } } 

net461目标框架名称(TFM)表示完整的桌面.NET Framework,如果要从此框架引用System.Runtime ,则需要将"System.Runtime": "4.0.0.0"条目移动到frameworkAssemblies节点。