类型定义存在于两个库 [英] Type definition exists in two libraries

查看:165
本文介绍了类型定义存在于两个库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立一个ASP.NET Web窗体使用.NET 4.5的网站。

I am building an ASP.NET Web Forms web site using .NET 4.5.

错误...

The type 'System.ComponentModel.DataAnnotations.Schema.ForeignKeyAttribute' exists in both 'f:\Projects\web sites\RC1Iteration05\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll' and 'c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ComponentModel.DataAnnotations.dll'

我曾尝试使用别名库...

I have tried to alias the libraries using ...

csc /r:EF_DataAnnotations="f:\Projects\web sites\RC1Iteration05\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll" /r:CM_DataAnnotations="c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ComponentModel.DataAnnotations.dll"

但这只是导致未指定源文件,因为按照指示(的这里和放大器; 这里)。

我也注意到,错误是引用了net40文件夹,而不是net45文件夹中的EF DLL。我想如果我用了net45的版本问题会自行解决,但我不知道该如何改变这种状况的参考。我改变了targetFramework属性到的EntityFramework包中的文件packages.config,但没有任何区别。

I did notice that the error was referencing the EF dll in the net40 folder rather than the net45 folder. I figure if I used the net45 version the problem would resolve itself, however I do not know how to change that reference. I changed the "targetFramework" attribute to the EntityFramework package in the packages.config file, but that did not make any difference.

我有点由于两个方案的卡似乎并没有做任何事情。

I am a bit stuck since both of the solutions did not seem to do anything.

我环顾四周,发现了一些在这里的帖子,其中乡亲处理类似的问题,但没有收到任何回应。我希望有一个人在那里谁可以帮助!

I looked around and found a number of posts here where folks have dealt with similar issues but have received no responses. I am hoping that there is someone out there who can help!

感谢

推荐答案

当你发现,你正在使用的.NET 4.5的.NET 4.0版本的实体框架。结果
这是行不通的。

As you noticed, you're using the .Net 4.0 version of Entity Framework on .Net 4.5.
That won't work.

从的NuGet重新安装EF,它应该工作正常。

Re-install EF from NuGet and it should work fine.

这篇关于类型定义存在于两个库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆