Introduction to the Eclipse Modeling Framework (EMF)


This eclipse project is a modelling framework which also provides application building tools.
In short, it offers you the tools to create your data model and then generate code based on it.

This is done in 2 steps:
1. Modelling:
Basically you define the domain model objects your application will be using. This model is saved in an .ecore file(usually under the model folder in your eclipse modelling project).
The Ecore model allows to define different elements:

EClass : represents a class, with zero or more attributes and zero or more references.

EAttribute : represents an attribute which has a name and a type.

EReference : represents one end of an association between two classes.

EDataType : represents the type of an attribute(e.g. EString – java.lang.String)

Eclipse modelling plugins provides you an editor in which you can describe it like a tree structure. It is ok for smaller models with a few objects.


A better way is using the ecore tools eclipse plugin. It has a diagram editor which helps a lot with the readability of the model. A thing to remember is to create a new ECORE MODELLING PROJECT instead of a new Empty EMF project(like you will find in most tutorials…) if you want to be able to create these diagrams(stored in the aird file).

2. Code generation

Code generation also needs a generator model. This contains properties for the code generation which are outside of the model structure scope(e.g. package information for the generated classes).
It is created based on an existing ecore model. With these two, model code can be generated(right clicking the root node of the generator model).

Eclipse offers the following items to be generated:
– Model: The model contains all entities, packages and factories to create instances of the model.

– Edit: The edit plugin contains providers to display a model in a UI. For example, the providers offer a label for every model element, which can be used to display an entity showing an icon and a name.

– Editor: The editor plugin is a generated example editor to create and modify instances of a model.

– Test: The test plugin contains templates to write tests for a model.

The plugins can be used directly by integrating them in an eclipse rcp application. Of course the generated code can be refined and you can also build a more user friendly user interface. EMF Forms framework can be used to create a proper UI.

By continuing to use the site, you agree to the use of cookies. More information

The cookie settings on this website are set to "allow cookies" to give you the best browsing experience possible. If you continue to use this website without changing your cookie settings or you click "Accept" below then you are consenting to this.