In this video you will learn how to define one to many, and many to many associations between entities using the visual designer.
The Association Editor is the place where you create (or edit) the associations between your entities.
The Association Editor contains the following options:
Association Name - defines the name of the association.
Object View - here you should define the navigation ends, as well as the target properties (primary key/foreign key) for the navigation. The Target Class describes the parent entity in the association. The Source Class describes the child entity in the association. You may consider the child entity as the entity that will hold the foreign key. For example, Product can have one instance of Category. Category can have many instances of Product. Source/Target Properties grid defines the properties that participate in the association. By default when you create a new association the target property will be the primary key of the Target Class. However, the source property won't be defined. The reason is that Telerik OpenAccess ORM cannot resolve which property is the foreign key in the Source Class. That's why you have to define it manually.
To specify the source (foreign key) property, click on the first cell in the Source Properties column. A new combo box with all properties of the Source class will appear.
Here you should specify which property in the Source entity is the foreign key. Or, you could use the (Default) option. When you don't have a foreign key defined in the source class, then you have to use the (Default) option. When you use the (Default) option for a foreign key, then Telerik OpenAccess ORM will create automatically a foreign key column. If you use the (Default) option for the primary key (the target property), then Telerik OpenAccess ORM will try to map to the default identity of the target class.
You could choose whether to generate the Navigation Property for the Target End via the Target End (Navigation Property) check box. Also, you could rename the navigation properties.
The Relational View allows you to specify the database tables and columns that participate in the association. If your classes are mapped to database tables, then these tables will be selected automatically in the Foreign/Primary Key Table drop-downs. Telerik OpenAccess ORM cannot determine the foreign key for the association. Again you have to specify it manually. If you want to create many-to-many, then you need to check the Use Join Table option and to select the join table from the drop-down.
For more information, see: