Create an LLBLGen Pro project

This tutorial guides you to the first steps of using LLBLGen Pro: the steps to create a new LLBLGen Pro project from an existing database schema. It refers to the LLBLGen Pro designer to give you a complete from-start-to-finish experience.

Steps to create a project

Please follow the following steps to create a new LLBLGen Pro project from an existing database schema. SQL Server and 'Northwind' will be used as the targets, but you're free to select a different database type and database schema.

  • Start the LLBLGen Pro designer. Either use the Programs start menu or double click the LLBLGenPro.exe in the installation folder to start the LLBLGen Pro designer.
  • Select File -> New Project... or press Ctrl-N. The Create New Project dialog opens.
  • Specify the name of the project, e.g. Northwind, and the name of the creator of the project, which is normally the user's name or the name of the organisation / deparment creating / owning the project. Check if the Location textbox indeed points to the folder you normally would want to save the project file to. If not, click the [...] button next to the Location textbox to select a different folder.
  • Select as target framework LLBLGen Pro Runtime Framework.
  • Click the OK button. The designer creates a default, empty project for you with Project Settings derived from the designer Preferences.
  • Right-click the 'Relational Model Data' node in the Project Explorer and select 'Add Relational Model Data from a Database'. The wizard starts.
  • Select the database driver matching the database type to connect to. For this tutorial we'll connect to SQL Server and we therefore select the SQL Server 2000-2016 Driver (SqlClient).
  • Specify the authentication information. If you're working locally and you're running the designer as administrator, you could leave WindowsAuthentication selected for Authentication Type. If you want to connect to a remote server instance, it might be you need to specify a database account, e.g. sa and its password.
  • Specify the server name. For server name, specify for example myserver.domain.com or if you're working locally on a SqlExpress installation, you probably need to use .\SQLEXPRESS
  • Click Next.
  • The SQL Server driver will now obtain all catalogs (databases) in the SQL Server instance you connected to as well as the schemas and tables, views and stored procedures, if you click open a node, to which the user you used to connect with as access.
  • We're creating a project on Northwind, so we'll check the checkbox in front of Northwind in the list. This will check the 'dbo' schema and all tables, stored procedures and views in Northwind. Click Next.
  • The wizard shows the stored procedures found. Check the checkbox in front of 'SalesByYear' and click Next and Finish.
  • LLBLGen Pro now knows enough information to obtain the meta-data for the project and will retrieve the meta data for the specified catalogs, in this case 'Northwind', from the database server.

You now have an LLBLGen Pro project with all the relational model data from the catalog(s) you specified, in this case Northwind, so you can design the entities without having to connect to the database server.

If you open the Catalog Explorer (which is might be hidden away in a tab at the right edge of the LLBLGen Pro designer. Just click the tab to make it slide into view), you can browse through the meta-data retrieved by the designer. When you click schemas, tables or their subnodes, press Ctrl-Shift-D or right-click and select Show Details to open a tab with additional meta-information of the node(s) currently selected.

It's now time to do something useful with this meta data: map entities and other elements onto the tables and views!

Creating project elements

First we'll create some entities mapped onto the Northwind tables. As we already have relational model data in the form of table information, we'll use reverse engineering, aka Database First to let the designer create the entity definitions and mappings for us.

Mapping entities

  • To create entities mapped onto tables, right-click in Catalog Explorer on the 'Northwind' node and select 'Reverse Engineer Tables to Entity Definitions' from the context menu.
  • The dialog to select which entities to create opens, showing all database tables in the catalog and entity names of the entities to map on these tables. If the checkbox of an element isn't checked, use the Checking and Selecting tools in the lower left corner of the dialog to select all rows and check the checkboxes of the selected rows. You can rename entity names here if you want to and assign a groupname to one or more elements if needed. When everything looks OK, click Add to Project.
  • In the Project Explorer, all entities you've added are now present. LLBLGen Pro automatically detected the relationships between the entities you've specified (if there were any FK constraints defined in the database, and Northwind has these defined). All fields are mapped by default to a table field. Please expand some entity nodes to see that the entities indeed are filled with fields and relations.
  • Save your work. It's now a good time to save the project. Click File -> Save Project (or press Ctrl-S) to save the project to the Location specified when the project was created.
  • To examine an entity in detail, right-click the entity in the Project Explorer -> Edit. This will open the Entity Editor. You can also double-click the entity or press Ctrl-Shift-O while the entity is selected in the Project Explorer.

After we've mapped some entities, we'll now map a TypedView onto a database view, namely Invoices.

Mapping a typed view

  • To map a TypedView onto a database view, right-click the view 'Invoices' in Catalog Explorer and select 'Reverse Engineer to Typed View Definition(s)' from the context menu. The dialog we've already seen in step 1 when we're mapping entities pops up, however this time it shows only the Invoices view. Check the checkbox in front of the Invoices view and click Add to project.
  • In the Project Explorer the Invoices typed view has been added below the Typed Views node, including a field mapped onto each database view field. To see the TypedView in detail, right click it and select Edit... or double click it.
  • We'll make sure we're generating the Typed View as a POCO class for QuerySpec (so the designer will generate QuerySpec oriented query elements for us) by opening the Project Settings using the designer menu Project -> Settings. Navigate in the tree in the Project Settings to the LLBLGen Pro Runtime Framework node and click it. On the right, under Defaults make sure the setting Typed View output type default is set to PocoWithQuerySpecQuery. Click OK to close the Settings dialog.
  • Save your project.

Mapping a stored procedure call

LLBLGen Pro also allows you to map methods to a stored procedure. In this tutorial we'll add a Retrieval Stored Procedure call to the SalesByYear stored procedure in Northwind

  • In the Catalog Explorer, right click the stored procedure SalesByYear and select Create Stored Procedure Call Definitions from the context menu. The Reverse Engineering dialog with the stored procedure SalesByYear is shown
  • Make sure the checkbox in front of 'SalesByYear' is checked and click Add to project.
  • Below Stored Procedure Calls in the Project Explorer, LLBLGen Pro has added the stored procedure including its parameters.
  • Save your project.

You've now created an LLBLGen Pro project which has entities mapped onto tables, a typed view mapped onto a database view and a stored procedure call mapped onto a stored procedure.

In the following tutorials we'll use this project to create a small application which will show how to use the entities, the typed view and the stored procedure in your own code.