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. Kafka:ZK+Kafka+Spark Streaming集群环境搭建(十三)kafka+spark streaming打包好的程序提交时提示虚拟内存不足(Container is running beyond virtual memory limits. Current usage: 119.5 MB of 1 GB physical memory used; 2.2 GB of 2.1 G)

    异常问题:Container is running beyond virtual memory limits. Current usage: 119.5 MB of 1 GB physical mem ...

  2. "Value does not fall within the expected range" with managed metadata fields

      From: http://geekswithblogs.net/claraoscura/archive/2011/01/21/143569.aspx The problem: I have an ...

  3. Android Toast 使用总结

    本文内容 环境 演示 Toast 使用 环境 Windows 2008 R2 64 位 Eclipse ADT V22.6.2,Android 4.4.3 三星 SM-G3508,Android OS ...

  4. junit mockito

    package com.zendaimoney.util; import static org.mockito.Mockito.*;import static org.junit.Assert.*;i ...

  5. html块元素和内联元素

    html块元素和内联元素: 对于html各种标签/元素,可以从块的层面做一个分类:要么是block(块元素),要么是inline(内联元素). block元素的特点: 总是另起一行开始: 高度,行高以 ...

  6. 微软BI 之SSRS 系列 - 使用带参数的 MDX 查询实现一个分组聚合功能的报表

    基于数据仓库上的 SSRS 报表展示,一般可以直接通过 SQL 查询,存储过程,视图或者表等多种方式将数据加载并呈现在报表中.但是如果是基于 Cube 多维数据集的数据查询,就不能再使用 SQL 的语 ...

  7. vsphere HA内幕变化

    see aslo:http://www.yellow-bricks.com/vmware-high-availability-deepdiv/ HA Deepdive My posts on VMwa ...

  8. 简单的WebRTC例子

    webrtc网上封装的很多,demo很多都是一个页面里实现的,今天实现了个完整的 , A 发视频给 B. A offer.html作为offer <!DOCTYPE html> <h ...

  9. 国外某牛人的JsonModelBinder 实现 MVC 3.0

    public class JsonModelBinder : DefaultModelBinder { public override object BindModel(ControllerConte ...

  10. javascript将算法复杂度从O(n^2)做到O(n)

    compare the difference of two giving array, return results: 1. elements in both array, 2. elements o ...