比如,定义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. nginx 错误集锦

    1)下载地址 http://nginx.org/en/download.html 找windows的下载. 2)然后解压到自己的一个目录. 3)配置环境变量,将解压到的路径加进去. 4)修改配置文件 ...

  2. Go语言学习之介绍与环境搭建

    Go语言第一课 一.Go语言介绍 1.什么是Go语言? Go 是一个开源的编程语言,它能让构造简单.可靠且高效的软件变得容易. Go是从2007年末由Robert Griesemer, Rob Pik ...

  3. ssy-publish

    github地址: https://github.com/shangyueyue/ssy-publish 一.安装 npm install ssy-publish -D 二.在process.cwd( ...

  4. 软件-绘图-AutoCAD:百科

    ylbtech-软件-绘图-AutoCAD:百科 AutoCAD(Autodesk Computer Aided Design)是Autodesk(欧特克)公司首次于1982年开发的自动计算机辅助设计 ...

  5. react-native-swiper设定高度的方法(设置rn轮播图所占高度)

    效果图: 直接上解决方案: 1.在Swiper标签外套一层View <View style={styles.container}> <Swiper style={styles.wra ...

  6. python之scrapy模块scrapy-redis使用

    1.redis的使用,自己可以多学习下,个人也是在学习 https://www.cnblogs.com/ywjfx/p/10262662.html官网可以自己搜索下. 2.下载安装scrapy-red ...

  7. 纯CSS实现加载转圈样式

    不同的项目中对于等待加载时转圈圈的样式是不同的,有的是传统的转圈的gif图片,见得比较多的是将转圈圈的换成了可爱的图标.有时候项目中加入等待加载的图片会很违和,不符合美观,所以需要用CSS做一个.下面 ...

  8. Qt可扩展窗口实现

    前言 有时候需要实现窗口可扩展,换句话说有一部分widget能够隐藏,显示,并且对话框大小可以随着widget变动而做出相应的变化:如图: 在点击CheckBox时,GroupBox_2能够显示,取消 ...

  9. Qt 字符映射表 显示图标

    一.利用字符映射表segmdl2.ttf,窗体显示字符图片. 在win10里面搜“字符映射表”,选择字体segmdl2.ttf,查看图标对应得16进制值.把此字体拷贝到程序的目录下. 二.使用 #if ...

  10. Prettier格式化配置

    HTML/CSS/JS/LESS 文件的 prettier 格式化规则 { // 使能每一种语言默认格式化规则 "[html]": { "editor.defaultFo ...