您的位置:首页 > 其它

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

2017-04-18 10:56 1116 查看
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更新

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐