How to fill out Associations Dialog Box?

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
GregJ
Posts: 2
Joined: Mon 05 Dec 2011 15:18

How to fill out Associations Dialog Box?

Post by GregJ » Mon 05 Dec 2011 15:58

After reading the help file and looking at sample diagrams, I still do not understand the Associations Editor dialog box. :( Could someone explain how I need to fill out the Association Dialogs? I will (hopefully) come to understand the dialog box through the solution to what I am trying to do.

I am trying to create a diagram (model first) to be used with NHibernate. With the class and property names changed to protect the innocent, it has a "Humans" class of which an instance represents a person such as "Bob." I have another class "Hobbies" of which each instance represents a Hobby such as "Crafting Piñatas" or "Making Mouse Traps." I have a class "HobbyType" that represents types of hobbies such as "Crafts" or "Outdoor Adventures."

The Humans class has a property named "HisHobbies" which I want to hold a set of instances of Hobbies (in relational-speak, presumably a set of Hobbies.HobbiesIDs). The Hobbies table has a property named "HobType" which should be a reference to a single instance of HobbyType.

How do I fill out the Association Dialogs to do this?

Thanks,
Greg

Shalex
Site Admin
Posts: 8247
Joined: Thu 14 Aug 2008 12:44

Post by Shalex » Tue 06 Dec 2011 18:10

Please create three classes on your diagram:
- Humans with properties: HumanId (primary key), Name
- Hobbies with properties: HobbyId (primary key), Name
- HobbyTypes with properties: HobbyTypeId (primary key), Name

Add associations in the following way:

1) right click on the Hobbies class > Add > Association and set
End 1 -
Class: Hobbies
Multiplicity: 1 (One)
Generate related property (selected)
Primary key of Hobbies (selected)
End 2 -
Class: Humans
Multiplicity: *(Many)
Generate related property (selected)
Collection type: Set
and press OK.

2) right click on the HobbyTypes class > Add > Association and set
End 1 -
Class: HobbyTypes
Multiplicity: 1 (One)
Generate related property (selected)
Primary key of HobbyTypes (selected)
End 2 -
Class: Hobbies
Multiplicity: *(Many)
Generate related property (selected)
Collection type: Set
and press OK.

Then right click on the diagram surface > Generate Database Script From Model, navigate through the wizard steps and make sure that the correct script for the database is generated.

GregJ
Posts: 2
Joined: Mon 05 Dec 2011 15:18

Thanks

Post by GregJ » Tue 06 Dec 2011 20:10

Thank you.

Post Reply