Creating an entity model using the entity editor

Besides using Quick Model, you can also add an entity model through the entity editor. Below we're going to create a small entity model of Customer - Order - OrderLine.

Adding the entity definitions

  • 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.
  • Right-click the Entities node below the expanded folder icon in Project Explorer and select New entity. Alternatively you can select from the menu Project -> New -> Entity Entity or press Ctrl-Shift-E. The new entity dialog opens. Specify Customer as the entity name and click OK. The entity editor for Customer opens.
  • Perform the previous step too for the entities Order and OrderLine.
  • You'll now have an entity model with three entities, although no fields nor relationships. All entities are open in their editors. Navigate to the open Customer editor tab by using Ctrl-Tab. Click on the new field row in the field grid, and specify the field: Id of type int and check the 'Is PK' checkbox. Use the Tab key to navigate between columns. Press Tab after the 'Is PK' column and press Ctrl-Enter to add the new field. Pressing Enter navigates to the next column and will add the field after the last column has been reached. Ctrl-Enter is a quick shortcut for added the field immediately. Be sure to Tab over a column to set its value. It's OK if you make a mistake, you can change any value in the grid at any time.
  • Press Ctrl-Shift-F to go back to the new field row in the grid to add a new field. Use this mechanism to add the following fields:
    • CompanyName, string (with max length 100)
    • Address, string (with max length 100), Is Optional
    • City, string (with max length 75), Is Optional
    • Country, string (with max length 50), Is Optional
  • Use Ctrl-Tab to navigate to the Order editor. Use the mechanism illustrated above to add the following fields:
    • Id, int, Is PK
    • OrderDate, DateTime
    • ShippingDate, DateTime, Is Optional
  • Use Ctrl-Tab to navigate to the OrderLine editor. Use the mechanism illustrated above to add the following fields:
    • Id, int, Is PK
    • Product, string (with max length of 100)
    • Quantity, int
    • Price, decimal (with precision 10 and scale 2)
  • Save your project, e.g. by pressing Ctrl-S.

Adding the relationships.

The entity model doesn't have relationships yet, so we're going to add them next

  • In Project Explorer expand the Customer node and right-click the Relationships node and select New Normal Relationship. Alternatively you could select from the menu Project -> New -> Normal Relationship or press Ctrl-Shift-N. The normal relationship editor opens.
  • We're going to define the Customer 1:n Order relationship and two navigators mapped onto the relationship, one for Customer and one for Order. The relationship editor has already pre-selected Customer in the top combo box. Select below is related to the value Many in the left combo box and Order in the right combo box so it reads 0..1 Customer is related to Many Order.
  • The editor auto-creates navigators for you. It creates Orders as navigator mapped on the collection of Orders in *Customer. It creates Customer as the navigator mapped on the Customer instance related to a given Order.
  • In the Field Relationships you see the PK-FK relationships which form the base of any relationship. As there aren't any FK fields yet defined in Order, we leave the default so the designer will create a FK field in Order automatically. Click OK to create the relationship.
  • In Project Explorer expand the Relationships node below Customer to see that the relationship was indeed added. Below Navigators there's now a navigator present. Right-click the relationship and select Go to Related Entity to navigate to Order.
  • In Project Explorer, expand Order and right-click the Relationships node below the Order node and select New Normal Relationship. The now familiar relationship editor opens. Now we're going to add the Order 1:n OrderLine relationship. Below is related to, select Many in the left combo box and OrderLine in the right combo box and as we accept all the other elements in the editor, just click OK to create the relationship.
  • Go to the Order entity in its editor and the OrderLine entity in its editor and verify the FK fields have been added for you automatically.
  • Save your project, e.g. by using Ctrl-S.

Next step

The next step is adding a relational model data container for the relational model data created from the entity model and which will form your tables and constraints in the database: Add a relational model data container.