简体   繁体   English

实体类未从正确的基类继承

[英]Entity classes not inheriting from correct base class

I am using EF 6.0 in my application. 我在应用程序中使用EF 6.0。 My problem is simple but it still had me scratching my head.I am creating partial classes corresponding to the entity classes to implement some custom properties there in. 我的问题很简单,但仍然让我挠头。我正在创建与实体类相对应的部分类,以在其中实现一些自定义属性。

Since i am using EF 6, i am inheriting my implementation of the partial class from System.Data.Entity.Core.Objects.DataClasses.EntityObject But when i update the model from the DB, the auto generated designer file has all the partial entity classes inheriting from System.Data.Objects.DataClasses.EntityObject . 因为我使用的是EF 6,所以我从System.Data.Entity.Core.Objects.DataClasses.EntityObject继承了部分类的实现。但是,当我从数据库更新模型时,自动生成的设计器文件将包含所有部分实体从System.Data.Objects.DataClasses.EntityObject继承的类。 This is throwing compile time error "Partial declarations of 'EMS.DAL.Category' must not specify different base classes". 这将引发编译时错误“'EMS.DAL.Category'的部分声明不能指定不同的基类”。 'Category' being the partial entity class. “类别”是部分实体类。

Any pointers please about whats wrong, missing references or what? 任何有关错误之处,缺少参考文献或内容的指针都可以吗?

If you are using EF6 you need to use EF6 tooling. 如果您使用的是EF6,则需要使用EF6工具。 It is included in VS2013 but there is also a version EF6 tooling available for download for VS2012. 它包含在VS2013中,但还有一个版本EF6工具可用于VS2012 下载 If you use old tooling with EF6 you will end up having some intricate and hard to resolve issues because of changes to EF6 runtime. 如果您将旧工具与EF6配合使用,由于EF6运行时的更改,最终将遇到一些复杂且难以解决的问题。 Here is a blog post I wrote on this topic. 这是我写的关于此主题的博客文章

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM