比如,定义entity时指定一个外键,

[ForeignKey("CustomerID")]
public Customer Customer { get; set; }

编译时报错信息如下:
类型“System.ComponentModel.DataAnnotations.Schema.ForeignKeyAttribute”同时存在于“e:\个人\Wede框架\WedeNet\packages\EntityFramework.5.0.0\lib\net40\EntityFramework.dll”和“c:\Program
Files (x86)\Reference
Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.ComponentModel.DataAnnotations.dll”中

解决方法:
1、引用目录下右键EntityFramework,打开属性页;
2、设置别名,把默认的Global修改为EF;

这样,就不会再提示命名冲突了。但是这时候原来可以正常引用EntityFramework.dll的地方现在都需要重新指定了。如下:
3、在需要引用的文件using最上面,加上extern alias EF;
4、原来的属性前面也要加上EF::,如下图:

 
参考:
https://stackoverflow.com/questions/10841393/cant-compile-c-sharp-project-because-of-some-tuple-error-when-referencing-an-ex/10841652#10841652
http://blog.csdn.net/lichxi1002/article/details/46986787

http://www.mamicode.com/info-detail-1766068.html

解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突的更多相关文章

  1. System.ComponentModel.DataAnnotations.Schema 冲突

    System.ComponentModel.DataAnnotations.Schema 冲突 Entity Framework 与 .net4.5 的 System.ComponentModel.D ...

  2. System.ComponentModel.DataAnnotations 冲突

    项目从原来的.NET Framework4.0 升级到 .NET Framework4.5 编译报错. 查找原因是: Entity Framework 与 .net4.5 的 System.Compo ...

  3. System.ComponentModel.DataAnnotations.Schema.TableAttribute 同时存在于EntityFramework.dll和System.ComponentModel.DataAnnotations.dll中

    Entity Framework 与 .net4.5 的 System.ComponentModel.DataAnnotations 都有 System.ComponentModel.DataAnno ...

  4. 对System.ComponentModel.DataAnnotations 的学习应用

    摘要 你还在为了验证一个Class对象中很多数据的有效性而写很多If条件判断吗?我也同样遇到这种问题,不过,最近学了一项新的方法,让我不在写很多if条件做判断,通过给属性标注特性来验证数据规则,从此再 ...

  5. System.ComponentModel.DataAnnotations 命名空间和RequiredAttribute 类

    System.ComponentModel.DataAnnotations 命名空间提供定义 ASP.NET MVC 和 ASP.NET 数据控件的类的特性. RequiredAttribute 指定 ...

  6. 使用System.ComponentModel.DataAnnotations验证字段数据正确性

    在.NET MVC 中,当页面提交model到Action的时候,自动填充ModelState.使用ModelState.IsValid进行方便快捷的数据验证,其验证也是调用命名空间System.Co ...

  7. C# 特性 System.ComponentModel 命名空间属性方法大全,System.ComponentModel 命名空间的特性

    目录: System.ComponentModel 特性命名空间与常用类 System.ComponentModel.DataAnnotations ComponentModel - Classes ...

  8. “CreateRiaClientFilesTask”任务意外失败。 未能加载文件程序集“System.ComponentModel.DataAnnot...

    错误  77  “CreateRiaClientFilesTask”任务意外失败.  System.Web.HttpException (0x80004005): 未能加载文件或程序集“System. ...

  9. Jquery库及其他库之间的$命名冲突解决办法

    首先我们应该知道,在jquery中,$(美元符号)就是jquery的别名,也就是说使用$和使用jquery是一样的,在很多时候我们命名空间时,正是因为这个$而产生的冲突的发生.比如说:$('#xmla ...

随机推荐

  1. Android即时通讯开发之XMPP (一)初识XMPP协议和asmack

    在讲XMPP和asmck之前 ,我还是先分享一些资源文档,如果你有耐心,可以直接忽略我下面所写的.下面有关XMPP的介绍大部分是摘抄网上的文档,后面我会写一些基于XMPP协议和asmck开源库的聊天室 ...

  2. C# List中的ForEach

    ; List<string> aaa = new List<string>(){ "aaa", "bbb" }; aaa.ForEach ...

  3. 【8583】ISO8583报文解析

    ISO8583报文(简称8583包)又称8583报文,是一个国际标准的包格式,最多由128个字段域组成,每个域都有统一的规定,并有定长与变长之分. [报文格式] POS终端上送POS中心的消息报文结构 ...

  4. LC 926. Flip String to Monotone Increasing

    A string of '0's and '1's is monotone increasing if it consists of some number of '0's (possibly 0), ...

  5. Hander创建消息

    每一个消息都需要被指定的Handler处理,通过Handler创建消息便可以完成此功能.Android消息机制中引入了消息池.Handler创建消息时首先查询消息池中是否有消息存在,如果有直接从消息池 ...

  6. ASP.NET的IIS映射

    ASP.NET默认扩展名为.aspx,可是我们看到许多网站的扩展名很特别,比如校内的do.个性之余还可以实现简单的伪静态(即把后缀改为html) 不过相对URLRewriter来说,是有点简陋(只能改 ...

  7. npm publish 发布失败 无法连接 https://registry.npmjs.org

    自己写的npm包,之前每次更新都是正常发布,最近做个一个更新,想发布,然后npm publish 竟然失败, 错误提示如下: npm ERR! network request to https://r ...

  8. 数组中存放model去重

    在这个项目中出现"添加model数据"数组重复的情况,这就涉及到数组去重的问题了...... 1. 一开始使用的最笨的方法: 依次循环两个数组(原有的数组,选择的数组),双重for ...

  9. Data - 大数据分析学习之路

    一.大数据分析的五个基本方面 可视化分析 大数据分析的使用者有大数据分析专家,同时还有普通用户,但是他们二者对于大数据分析最基本的要求就是可视化分析,因为可视化分析能够直观的呈现大数据特点,同时能够非 ...

  10. 使用Visual Studio Code Coverage和nunit上传单元测试覆盖率和单元测试结果到SonarQube上

    SonarQube.Scanner.MSBuild.exe begin /k:"OMDCCQuotes" /d:sonar.host.url="http://myip:9 ...