2015-11-19 27 views
5

我使用VS2015社区,我已经安装了.NET 4.6.01040我也跟着these说明安装ASP.NET 5的IEnumerable <>在未引用的程序定义 - 新的NuGet类库项目

我想开始将一个站点从MVC5迁移到MVC6所附带的所有其他更新,因此我开始使用包含我的数据模型的实体类库项目。这是我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 

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

+0

忘了提,我试着用'net46'以及前'net461' 。我安装了.NET 4.6.1 RC,因为我认为它可能会工作 – GregoryHouseMD

+1

哦,等等,试着把'System.Runtime'软件包引用放在'net46'的'frameworkAssemblies'节点下,然后尝试 –

+0

谢谢:)我不得不重新打开Visual工作室摆脱错误,但它的工作 – GregoryHouseMD

回答

7

由于并不清楚,我从需要的是什么答案,我会在这里提供它....

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

net461目标框架名称(TFM)代表完整的桌面.NET框架,如果你想从这个框架引用System.Runtime,您需要将"System.Runtime": "4.0.0.0"进入移动到frameworkAssemblies节点。

+0

它与最新的4.0.2.0版本以及 – GregoryHouseMD

相关问题