For unidirectional relations no annotations at all are necessary for re motion to automate the mapping to the database in a meaningful way. re-motion simply takes a .NET declaration in the
Person class like
to mean "there is a unidirectional relationship between
Location", and there will be a foreign key in the
Person table to its
Location row in the
Location table. Things are not as easy for bidirectional relationships, as we will see shortly.
If domain objects were not persisted in database tables we'd have difficulty finding all
Person objects belonging to a given
Location, because the .NET Location object can't be asked for it. Since domain objects are always persisted in a database, however, we can query the
Person table for a given location and wrap up the query in a member function for the
Location class. For bidirectional relations, re-motion generates such queries for keeping the .NET properties in sync with the database for you, and makes sure they work correctly at both ends of the relation. A unidirectional
relation, however, lacks this automation in the other direction, in this case the query for getting the persons belonging to a location.