Can nirernate / orm support?

I recently inherited a system that relies heavily on the EAV database structure and really fights in terms of performance.

I want to use nhibernate or another suitable ORM product to map these EAV tables to objects so that we can map a row to a property. Then we can reorganize the database to make it relational. Does anyone know if this is possible? An example will also be appreciated! :)

To make you feel the structure, it looks something like this:

Entity (EntityId) EntityVarchar (EntityId, VarcharValue) EntityFloat (EntityId, VarcharValue)

etc. If I had a Customer object, I would say Customer.Name to get the name, not Customer.Varchar ["Name"].

Please note that there is no need to use the EAV model in our system, we do not allow runtime changes in data structures, and I think this is bad practice.

+4
source share
1 answer

I don’t think it will be that simple. Although there are generators that can read the database schema and generate matching and classes, this will only result in an access level for your existing eav db. To create a relational version of this db, you will need to read the data and create new domain objects containing properties for the values ​​set in your db. This will most likely lead to the creation of one large table containing all the properties in eav db. Therefore, I believe that the best approach would be to create a relational database model manually by analyzing existing data and taking into account the needs of your application. Especially table inheritance should be your friend here. Then, after you have created access levels for both schemes, you still have to write a mapping to transfer data.

+1
source

All Articles