GMF / EMF / Ecore

By using the “EOpposite” feature, you can have models instead of:

- Page A
  - Link Z to: Page B
- Page B

To be instead:

- Page A
  - Link Z to: Page B
- Page B in: Z

More information about this is available in the article on Ecore, specifically I want to be able to go backwards through a reference.

Set EOpposite properly in the Ecore model

In the example above, you want the following model:

- Page
  - reference "in": 0..* of type Link
  - containment reference "links": 0..* of type Link, containment is true
- Link
  - reference "to": 1 of type Page

To set EOpposite properly, you want to change this to:

- Page
  - reference "in": 0..* of type Link, EOpposite is Link.to
  - containment reference "links": 0..* of type Link, containment is true, EOpposite is Link.from
- Link
  - reference "to": 1 of type Page, EOpposite is Page.in
  - reference "from": 1 of type Page, EOpposite is Page.links
  1. Regenerate the .genmodel from your changed .ecore file
  2. Regenerate the Model, Edit and Editor code
  1. In Link Mapping, make sure Source Feature and Target Feature are properly set.
  2. Regenerate the .gmfmap file
  3. Regenerate the diagram code