码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2017-04-18 11:15:34      阅读:1673      评论:0      收藏:0      [点我收藏+]

标签:ble   component   data   ram   model   分享   logs   pos   sys   

 

 

Entity Framework 与 .net4.5 的 System.ComponentModel.DataAnnotations 都有 System.ComponentModel.DataAnnotations.Schema 命名空间。并且都有一些相同的 特性(Attribute), 如:ForeignKeyAttribute, NotMappedAttribute 等。当项目同时引用了 EntityFramework.dll 与 System.ComponentModel.Composition.dll ,你将不能正常使用上面提到的特性。

使用别名,给这两个dll 加一个不同的根。

引用dll, 默认的别名都是 global

1、将 EntityFramework.dll 的别名改为 EF

技术分享

 

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

3、using EF::System.ComponentModel.DataAnnotations.Schema;   //引用别名加命名空间

技术分享

 

 4、DbContext更新

技术分享

 

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

标签:ble   component   data   ram   model   分享   logs   pos   sys   

原文地址:http://www.cnblogs.com/valu/p/6726679.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!