System.ComponentModel.DataAnnotations 冲突
项目从原来的.NET Framework4.0 升级到 .NET Framework4.5 编译报错。
查找原因是:
Entity Framework 与 .net4.5 的 System.ComponentModel.DataAnnotations 都有 System.ComponentModel.DataAnnotations.Schema 命名空间。并且都有一些相同的 特性(Attribute), 如:ForeignKeyAttribute, NotMappedAttribute 等。当项目同时引用了 EntityFramework.dll 与 System.ComponentModel.Composition.dll ,你将不能正常使用上面提到的特性。
解决方案:
使用别名,给这两个dll 加一个不同的根。
引用dll, 默认的别名都是 global
将 EntityFramework.dll 的别名改为 EF
在namespace区域写入 extern alias EF;(原文中写的是在 类的using 区域写入 extern alias EF 我试下了不行,改成namespace区域)
*using EF::System.ComponentModel.DataAnnotations.Schema 引用别名加命名空间

参考:
http://blog.csdn.net/lichxi1002/article/details/46986787
System.ComponentModel.DataAnnotations 冲突的更多相关文章
- System.ComponentModel.DataAnnotations.Schema 冲突
System.ComponentModel.DataAnnotations.Schema 冲突 Entity Framework 与 .net4.5 的 System.ComponentModel.D ...
- 解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突
比如,定义entity时指定一个外键, [ForeignKey("CustomerID")] public Customer Customer { get; set; } 编译时报 ...
- 对System.ComponentModel.DataAnnotations 的学习应用
摘要 你还在为了验证一个Class对象中很多数据的有效性而写很多If条件判断吗?我也同样遇到这种问题,不过,最近学了一项新的方法,让我不在写很多if条件做判断,通过给属性标注特性来验证数据规则,从此再 ...
- System.ComponentModel.DataAnnotations.Schema.TableAttribute 同时存在于EntityFramework.dll和System.ComponentModel.DataAnnotations.dll中
Entity Framework 与 .net4.5 的 System.ComponentModel.DataAnnotations 都有 System.ComponentModel.DataAnno ...
- 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. ...
- 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问。
本地win7 本地正常,服务器win2008r2,服务器报错! 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问. 拒绝访问. 说明: 执行当前 W ...
随机推荐
- 【NOIP模拟】matrix(简化矩阵)
题目背景 SOURCE:NOIP2016-RZZ-1 题目描述 给出两个 N×N 的矩阵 A.B,矩阵每行每列标号 0-N-1 .定义这两个矩阵的乘积 AB 为
- <EffectiveJava>读书笔记--01继承的使用注意
1, 父类的构造器方法中不能调用能够被子类重写的方法. 分析: 当初始化一个子类时, 首先要初始化父类, 即调用父类的构造方法; 如果父类的构造方法中调用了可被重写的其它方法, 那么此时调用的其实是该 ...
- ECMAScript6新特性之let、const
第一次在博客园写博客,想把自己每一天学习到的知识点记录下来,心里有点紧张(PS:不知道自己能不能写好......嘿嘿).言归正传,咱们先来说说"ECMAScript"这到底是啥玩意 ...
- [补档]暑假集训D6总结
考试 不是爆零,胜似爆零= = 三道题,就拿了20分,根本没法玩好吧= = 本来以为打了道正解,打了道暴力,加上个特判分,应该不会死的太惨,然而--为啥我只有特判分啊- - 真的是惨. 讲完题觉得题是 ...
- acdsee-pro-8 英文版
目前中文版acdsee pro 8不支持破解,只能选择英文版,然后汉化. 但是英文版并不好找,我在这里分享一下. 下载地址:http://pan.baidu.com/s/1boNZxQf 同时附上注册 ...
- AndroidTv开发中常用的adb命令
盒子应用开发时,调试比手机上的开发比较麻烦一点,而且需要经常跟 adb 打交道,不管是 wifi 连接调试,还是应用删除安装等.这里记录一些常用的操作,方便查阅. adb wifi连接调试 方法一:需 ...
- 含有n个元素的整型数组,将这个n个元素重新组合,求出最小的数,如{321,3,32},最小的数为321323
public class GetMinNumber { public static void main(String[] args) { String[] arr = null; System.out ...
- 安装nginx+ngx_lua支持WAF防护功能
安装nginx+ngx_lua支持WAF防护功能 nginx lua模块淘宝开发的nginx第三方模块,它能将lua语言嵌入到nginx配置中,从而使用lua就极大增强了nginx的能力.nginx以 ...
- swift3.0 底部弹出菜单 UIAlertController的使用
let optionMenuController = UIAlertController(title: nil, message: "选择图片", preferredStyle: ...
- 如何开发自己的搜索帝国之ES图形化Kibana安装与使用
在如何开发自己的搜索帝国之Elasticsearch中已经介绍安装好了ES,下面就Kibana对ES的查询监控作介绍,就是常提到的大数据日志处理组件ELK里的K. 什么是Kibana?现引用园友的一段 ...