1. Is there a way to generate entities with if relationships in the database there are no restrictions?
Even if it was possible, it would be very error prone. On which rule can relationships be generated in an idiomatic and reliable way?
2. If you need to do it manually, what's the best approach?
If I were in your place, I would have done everything safely.
Manually adding all the relationships between objects after generating entities can be error prone and cumbersome.
Suppose you make mistakes during the entity generation phase (and you can see the number of tables), and you want to generate them again while you have already added a dozen and a dozen relationships to your entities.
By starting the generation again, you will lose all these manually added relationships in the entity.
You must start from scratch.
I think you should do the opposite.
You can, for example, create a copy of the database (I mean the copy, because I believe that if you do not have restrictions on the tables, it is intentional) and adds restrictions on the tables of the database copy.
Then, from these tables with the specified restrictions, you can create objects with all the necessary relationships.
This method provides two advantages :
The ability to provide quick feedback on whether the PK / FK restrictions you want to add are compatible with your existing data.
the ability to act in stages and be able to take some steps back if necessary.
For example, if you made mistakes during the entity creation phase (and you could make them see the number of tables), you can repeat the generation phase without losing the automatically generated relationship that arises from the PK / FK restrictions that you added to the tables.
source share