简体   繁体   English

创建一个BasePOCO(基本上类似于实体框架数据库的第一个EntityObject类)

[英]Created a BasePOCO (which basically is similar to Entity Frameworks Database First EntityObject class)

At work, there is an application was developed using Entity Framework Database First approach. 在工作中,有一个使用Entity Framework Database First方法开发的应用程序。 Therefore, our business entity classes are derived from Entity Framework Database First's EntityObject class. 因此,我们的业务实体类是从Entity Framework Database First的EntityObject类派生的。

Our team was to modify the application by moving from Entity Framework Database First approach to Entity Framework Code First approach. 我们的团队是通过从Entity Framework Database First方法过渡到Entity Framework Code First方法来修改应用程序的。

However, we have to modify all out business entity classes that derive by modifying them in such a way that they Stop inheriting from the EntityObject class. 但是,我们必须修改通过修改它们而派生的所有业务实体类,以使它们停止从EntityObject类继承。

The problem is that we use a lot of EntityObject class's methods and other features in a lot of classes. 问题在于我们在许多类中使用了许多EntityObject类的方法和其他功能。

We were planning to create a BasePOCO class that will replace the Entity Frameworks Database First EntityObject class. 我们正计划创建一个BasePOCO类,它将替换Entity Frameworks Database First EntityObject类。

We would have to implement some methods in the BasePOCO class that would function in the same manner as some methods in the EntityObject class. 我们将必须在BasePOCO类中实现某些方法,这些方法的功能与EntityObject类中的某些方法相同。

For example, we have the following line in a code file ( entity instance in the line of code below being of type EntityObject ) 例如,我们在代码文件中包含以下行(以下代码行中的实体实例的类型为EntityObject)

entity.GetType().GetProperty(firstFilter + _referenceKey); entity.GetType()。GetProperty(firstFilter + _referenceKey);

we can replace it with (we have to implement methods that do something similar): basePOCOEntityObject.GetType().GetProperty(firstFilter + _referenceKey); 我们可以将其替换为(我们必须实现执行类似操作的方法):basePOCOEntityObject.GetType()。GetProperty(firstFilter + _referenceKey);

I'm assuming there were probably many companies who moved from Entity Framework Database First approach to the Code First approach Therefore, Has anyone already created something like out BasePOCO (which basically has a lot of functionalities that is similar to Entity Frameworks Database First EntityObject class)? 我假设可能有很多公司从Entity Framework Database First方法转到Code First方法,因此,是否有人已经创建了BasePOCO之类的东西(基本上具有与Entity Frameworks Database First EntityObject类相似的许多功能) )?

GetType() is not an EntityObject method. GetType()不是EntityObject方法。 It's available on all objects. 它适用于所有对象。

EntityObject 's methods mostly are replaced by methods on the DbContext.ChangeTracker. EntityObject的方法大部分被DbContext.ChangeTracker上的方法取代。 The main difference is that you have to have a DbContext object to call these methods. 主要区别在于您必须具有DbContext对象才能调用这些方法。 This can require some code restructuring. 这可能需要一些代码重组。

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

相关问题 首先在WPF MVVM实体框架中初始化数据库的文件 - Which file to Initialize Database in WPF MVVM Entity Frameworks Code First 首先使用实体​​框架代码保存单个EntityObject - Saving single EntityObject with Entity Framework code first 检测实体框架 EntityObject 上的哪些属性发生了变化 - Detect which properties changed on an Entity Framework EntityObject 实体框架和数据库连接 - Entity Frameworks and database connections 从EntityKey构造EntityObject而不在Entity Framework中进行数据库调用 - Constructing EntityObject from EntityKey without a database call in Entity Framework 将代码优先实体框架指向创建的数据库 - Pointing a Code First Entity Framework to a created database 由实体框架自动创建的数据库的位置 - The location of a database which is created by entity framework automatically 可以在实体框架中创建一个类似于Fluent NHibernate中的映射类吗? - Can a mapping class be created in Entity Framework similar to this one in Fluent NHibernate? 如何用密码保护使用Entity Framework Code First创建的数据库? - How to password protect database that is created using Entity Framework Code First? 首先使用实体​​框架模型的多个表名 - Plural table names with Entity Frameworks Model First
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM