简体   繁体   中英

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. Therefore, our business entity classes are derived from Entity Framework Database First's EntityObject class.

Our team was to modify the application by moving from Entity Framework Database First approach to Entity Framework Code First approach.

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.

The problem is that we use a lot of EntityObject class's methods and other features in a lot of classes.

We were planning to create a BasePOCO class that will replace the Entity Frameworks Database First EntityObject class.

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.

For example, we have the following line in a code file ( entity instance in the line of code below being of type EntityObject )

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

we can replace it with (we have to implement methods that do something similar): 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)?

GetType() is not an EntityObject method. It's available on all objects.

EntityObject 's methods mostly are replaced by methods on the DbContext.ChangeTracker. The main difference is that you have to have a DbContext object to call these methods. This can require some code restructuring.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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