zoukankan      html  css  js  c++  java
  • 解决EntityFramework与System.ComponentModel.DataAnnotations命名冲突

    比如,定义entity时指定一个外键,

    [ForeignKey("CustomerID")]
    public Customer Customer { get; set; }
    

     
    编译时报错信息如下:
    类型“System.ComponentModel.DataAnnotations.Schema.ForeignKeyAttribute”同时存在于“e:个人Wede框架WedeNetpackagesEntityFramework.5.0.0lib et40EntityFramework.dll”和“c:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5System.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

  • 相关阅读:
    解决粘包问题
    粘包问题
    模拟ssh功能
    套接字接上链接循环
    套接字加入通讯循环
    简单通信
    网络编程
    单例模式
    记录一下:chrome上,把网页保存为文件的插件
    centos6.5 64bit 实现root开机自动登录X桌面
  • 原文地址:https://www.cnblogs.com/zhaow/p/9753901.html
Copyright © 2011-2022 走看看