Search code examples
ormarchitecturedomain-driven-designdomain-object

Should I use my ORM generated objects as my domain object?


My ORM is generating objects reflecting the database table structure. This objects are extensible, so I'm able to add new properties and methods. This objects do not contains any persistence logic,so I guess they are persistant ignorant.

Should I use this object as my domain objects or should I create new objects for main domains model ?

As a pro for creating new object I would consider that when a database table changes it won't break the application.

As a con for creating new object I would consider the additional mapping and more complexity in the app.


Solution

  • My answer is, it depends. If you have a lot of complex logic assosiated with many entities you should create another layer of domain, but for the objects that got no logic and just serves you as a db port, don't bother to create a separate object cause its meaningless.

    To sum up, if a db change will cause domain change, don't separate if it won't, separate.