Relation Mapping

Topic updated 11-12-2007

When relations are found in the Database Repository they are by default mapped in the NHibernate templates.

Maps each many-to-one relation as a related object providing easy lookups and navigation. (Product object in Order lines)
Maps each one-to-many relation as child Collection. (Orderlines collection in Orders)
Relations are bi-directional by default.
Relations can be excluded from the model by using the IsMapped Template option.
One-to-many Relations can also be transformed into (or treated as)  1:1 by using the "Is One-One Relation" Template option. Please notice that this needs to be done only in the many side.

 

For example, take any of the imported tables and double click on that table, the Table Designer will open and there you should see the relations that apply to that table.

In the NHibernate Templates you can see the relations if you double click on the project item.

RelationMapping

In the image above you can see:

You can completely Turn OFF all mapped relations for this Item by using "Generate Relations as Properties"
You can turn OFF Parent Relations (many:1) , many:many, and Child Relations (1:many) by using the nested checkbox
You can turn EACH relation by ysing the IsMapped option inside each relation options.

 

Unmapping a relation

A Relation can be unmapped by turning off the "Is Mapped" Template option.

 

Related Topics

A Note about how GenWise calculates for each Relation (Auto-Calculated Options for Relations)