解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突
比如,定义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::,如下图:

http://www.mamicode.com/info-detail-1766068.html
解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突的更多相关文章
- System.ComponentModel.DataAnnotations.Schema 冲突
System.ComponentModel.DataAnnotations.Schema 冲突 Entity Framework 与 .net4.5 的 System.ComponentModel.D ...
- System.ComponentModel.DataAnnotations 冲突
项目从原来的.NET Framework4.0 升级到 .NET Framework4.5 编译报错. 查找原因是: Entity Framework 与 .net4.5 的 System.Compo ...
- System.ComponentModel.DataAnnotations.Schema.TableAttribute 同时存在于EntityFramework.dll和System.ComponentModel.DataAnnotations.dll中
Entity Framework 与 .net4.5 的 System.ComponentModel.DataAnnotations 都有 System.ComponentModel.DataAnno ...
- 对System.ComponentModel.DataAnnotations 的学习应用
摘要 你还在为了验证一个Class对象中很多数据的有效性而写很多If条件判断吗?我也同样遇到这种问题,不过,最近学了一项新的方法,让我不在写很多if条件做判断,通过给属性标注特性来验证数据规则,从此再 ...
- System.ComponentModel.DataAnnotations 命名空间和RequiredAttribute 类
System.ComponentModel.DataAnnotations 命名空间提供定义 ASP.NET MVC 和 ASP.NET 数据控件的类的特性. RequiredAttribute 指定 ...
- 使用System.ComponentModel.DataAnnotations验证字段数据正确性
在.NET MVC 中,当页面提交model到Action的时候,自动填充ModelState.使用ModelState.IsValid进行方便快捷的数据验证,其验证也是调用命名空间System.Co ...
- C# 特性 System.ComponentModel 命名空间属性方法大全,System.ComponentModel 命名空间的特性
目录: System.ComponentModel 特性命名空间与常用类 System.ComponentModel.DataAnnotations ComponentModel - Classes ...
- “CreateRiaClientFilesTask”任务意外失败。 未能加载文件程序集“System.ComponentModel.DataAnnot...
错误 77 “CreateRiaClientFilesTask”任务意外失败. System.Web.HttpException (0x80004005): 未能加载文件或程序集“System. ...
- Jquery库及其他库之间的$命名冲突解决办法
首先我们应该知道,在jquery中,$(美元符号)就是jquery的别名,也就是说使用$和使用jquery是一样的,在很多时候我们命名空间时,正是因为这个$而产生的冲突的发生.比如说:$('#xmla ...
随机推荐
- LeetCode 84. 柱状图中最大的矩形(Largest Rectangle in Histogram)
题目描述 给定 n 个非负整数,用来表示柱状图中各个柱子的高度.每个柱子彼此相邻,且宽度为 1 . 求在该柱状图中,能够勾勒出来的矩形的最大面积. 以上是柱状图的示例,其中每个柱子的宽度为 1,给定的 ...
- mysql 首次安装后 简单操作与语句 新手入门
首先cd到安装目录中bin路径:这是我的安装路径以管理员身份打开cmd(防止权限不足)cd E:\>cd E:\mysql\mysql-5.5.40-winx64\bin 首次安装需要输入 my ...
- Android 中更新 UI 的四种方式
runOnUiThread handler 的 post handler 的 sendMessage View 自身的 post
- 【转】实现1080P延迟低于500ms的实时超清直播传输技术
最近由于公司业务关系,需要一个在公网上能实时互动超清视频的架构和技术方案.众所周知,视频直播用 CDN + RTMP 就可以满足绝大部分视频直播业务,我们也接触了和测试了几家 CDN 提供的方案,单人 ...
- HDFS文件目录操作代码
分布式文件系统HDFS中对文件/目录的相关操作代码,整理了一下,大概包括以下部分: 文件夹的新建.删除.重命名 文件夹中子文件和目录的统计 文件的新建及显示文件内容 文件在local和remote间的 ...
- Jenkins+Ansible+Gitlab自动化部署三剑客
一.gitlab安装 环境:centos 7 x64 1.关闭防火墙 systemctl stop firewalld systemctl disable firewalld 2.禁用selinux ...
- 【学习笔记】XPath定位总结
XPath即为XML路径语言(XML Path Language),它是一种用来确定XML文档中某部分位置的语言. 原理:基于html的文档目录结构进行定位元素. 以html代码为例讲解各种定位方法: ...
- 安装keystone
在控制节点上执行 controllerHost='controller' MYSQL_PASSWD='m4r!adbOP' RABBIT_PASSWD='0penstackRMQ' ADMIN_PAS ...
- 用maven建立一个工程
建立java工程 mvn archetype:generate -DgroupId=cn.maxhou.demo -DartifactId=myapp -DarchetypeArtifactId=ma ...
- java api操作
java api操作 导入开发包 将hbase安装包中lib下包导入java项目 创建表 Configuration conf = HBaseConfiguration.create(); c ...