System.ComponentModel.DataAnnotations.Schema 冲突

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

  • 在类的using 区域写入 extern alias EF;

  • *using EF::System.ComponentModel.DataAnnotations.Schema 引用别名加命名空间

  • *

System.ComponentModel.DataAnnotations.Schema 冲突的更多相关文章

  1. 解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突

    比如,定义entity时指定一个外键, [ForeignKey("CustomerID")] public Customer Customer { get; set; } 编译时报 ...

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

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

  3. System.ComponentModel.DataAnnotations 冲突

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

  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. 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问。

    本地win7 本地正常,服务器win2008r2,服务器报错! 异常详细信息: System.ComponentModel.Win32Exception: 拒绝访问. 拒绝访问. 说明: 执行当前 W ...

随机推荐

  1. 以sb7code为基础创建一个基本的OpenGL项目

      以sb7code为基础创建一个基本的OpenGL项目   从github上面下载sb7code代码: https://github.com/openglsuperbible/sb7code 打开H ...

  2. JAVA对图片的任意角度旋转,以及镜像操作

    package relevantTest;/* * 该代码实现了对图像的水平镜像变换,垂直镜像变换,任意角度旋转,jtf的实时监控,以及对图像的缩放变换,以及按钮的若隐若现效果. * 在对图像进行任意 ...

  3. MODBUS协议整理——功能码简述

    1.Modbus简介——来自维基百科 Modbus是一种串行通信协议,是Modicon于1979年,为使用可编程逻辑控制器(PLC)而发表的.Modbus是工业领域通信协议的业界标准,并且现在是工业电 ...

  4. AI单挑Dota 2世界冠军:被电脑虐哭……

    OpenAI的机器人刚刚在 Dota2 1v1 比赛中战胜了人类顶级职业玩家 Denti.以建设安全的通用人工智能为己任的 OpenAI,通过“Self-Play”的方式,从零开始训练出了这个机器人. ...

  5. 循环插入oracle 存储过程

    -- Create tablecreate table STUDENTS( name VARCHAR2(300), id NUMBER(11), city VARCHAR2(300), no VARC ...

  6. Android开发点滴 - 实现层级式导航(API 16+)

    在Jelly Bean(API 16)以前,为了实现顶部的导航菜单,程序员们不得不手工写代码, 神马在OnCreate啊,神马onOptionsItemSelected啊,但是,现在一切都是浮云了. ...

  7. DIV+CSS IE6/IE7/IE8/FF兼容问题汇总

    1.IE8下兼容问题,这个最好处理,转化成ie7兼容就可以.在头部加如下一段代码,然后只要在IE7下兼容了,IE8下面也就兼容了 <meta http-equiv="x-ua-comp ...

  8. MicrosoftAjax.js

    MicrosoftAjax.js下载 Function.__typeName = "Function"; Function.__class = true; Function.cre ...

  9. Word 之 清除页眉下划线

    在应用 Word 的时候,有时我们需要为文件添加页眉,但是首页却不需要.这时一般都会勾选“ 首页不同 ”并关闭页眉页脚.一种情况页眉不显示任何信息及下划线,另一种情况页眉留有下划线.以下针对第二种情况 ...

  10. Angularjs乱记

    http://www.cnblogs.com/floor/p/6652313.html 在指令中使用filter DI规则 AngularJS注入规则 数据绑定 http://www.cnblogs. ...