TheCyberXP
TheCyberXP

Reputation: 915

EMF: How to setup a Many To Many Relationship with the EMF Tool

I would like to know how to setup a many to many relationship with EMF using the gui tool provided by EMF when creating my model? I can only add One To Many / One To One relationship.

Upvotes: 1

Views: 759

Answers (1)

Max Hohenegger
Max Hohenegger

Reputation: 1639

If you have a Class 'Foo' and a Class 'Bar' you would create a new reference 'bars' of type 'Bar' in the first, and a new reference 'foos' of type 'Foo' in the later. Both with 'Upper Bound' -1. Also you'll have to set the EOpposite of 'foos' to 'bars', and the other way around (which is done automatically). This way you get a many to many relationship between Foo and Bar that you can navigate both ways. For establishing this relationship between instances you only have to add, for example, one bar to a foo. This bar will then also reference that foo.

Upvotes: 4

Related Questions