Making changes to the entity model
To make changes to the entity model, you can use a variety of editors in the Designer, e.g. the Entity editor or the QuickModel editor. In this tutorial, we'll use both: the Quick Model editor editor to add a new entity and relationship, and the entity editor to add a new field.
Adding new elements to the entity model.
- Start the LLBLGen Pro designer. Either use the Programs start menu, Windows search or double click the LLBLGenPro.exe in the installation folder to start the LLBLGen Pro designer.
- To open our tutorial project, select it from the Recent Projects list on the Home Tab, or select File -> Open Project... from the main menu, or select the project from the File -> Recent Projects... menu.
- Open the Quick Model editor by selecting from the menu Project -> Quick Model Editor or press
F4
. The Quick Model editor tab opens. -
In the Command input are of the Quick Model editor you will specify the commands and facts, and thus also during this tutorial.
Every fact you type is ended with a carriage return which will make the editor to
interpret the fact and adjust the entity model accordingly. The model elements affected are included in the model view on the canvas above the command input. We'll
first add some entities to the canvas which are already there. Type in the Command input the following statements, follow each line with an
Enter
. You can also copy/paste the lines below and pressEnter
after the last line to add all fields in one go.
Order Customer
-
As you can see, the editor sees you typed the name of an existing element so it will re-use that element instead of creating a new one. Now let's create a new
relationship and entity, in one go. Type:
Order.Employee m1 Employee.Orders
followed by pressingEnter
. The designer will create a new entity and relationship. -
Let's switch to Employee by changing the scope to the Employee entity. To do that from within another scope we can specify the full name of the entity, which is groupname:entityname. As the group name is
empty, specify just
#u :Employee
followed byEnter
. - Add the following fields to the Employee entity, follow each line with an
Enter
. You can also copy/paste the lines below and pressEnter
after the last line to add all fields in one go.
Id int * FirstName string(50) LastName string(60) DoB datetime
-
Additionally to adding these fields to the Employee entity, the designer has also added a foreign key field to Order, namely EmployeeId, for the relationship Order m:1
Employee. This is a non-nullable field, however as Order already exists, we have to change it to a nullable field. To do so, simply specify the field with an aspect
of it and QuickModel will change it. First we'll go to the Order scope by typing:
#u :Order
followed by pressingEnter
. Then typeEmployeeId null
followed byEnter
. - We now are done adding the entity, and will now add a field to an entity. We can do that in QuickModel but we'll do it in the Entity Editor to illustrate its functionality. Right-click Order in the diagram inside QuickModel and select Edit... from the context menu.
-
Click the new row in the fields grid and specify for name: RequiredDate, for Type: datetime, and check the checkbox for Optional. Press
TAB
to move to the next column and pressCtrl-Enter
to add the field. - Save your project, e.g. by using
Ctrl-S
.
Next step
With the changes to the entity model now in-place we can proceed with the next step: Sync relational model data