Create DDL SQL Create Script
To export the created relational model data, the LLBLGen Pro designer supports the creation of DDL SQL scripts, for both update and create scripts. In the previous step the relational model data has been adjusted and now has to be exported to be created on the database server. This tutorial guides you through these steps.
Generating a Create DDL SQL script
- 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.
- To create a DDL SQL create script from the new relational model data created in the previous step of this quick-start guide, in Project Explorer right-click the Relational Model Data node and select Generate Database Schema Create Script (DDL SQL). Alternatively you can do this too from the Catalog Explorer or by selecting from the menu Project -> Generate Database Schema Create Script (DDL SQL)
- The Generate Code dialog opens. It contains one task, and as it doesn't know the target folder yet, it is invalid. Double-click the task or select it and click Edit selected task specifics.
-
In the Code generation task configuration dialog, specify a destination folder in Destination Root Folder for the DDL SQL script to be written to. E.g.
specify
.\
for the folder the LLBLGen Pro project is in. Click OK. The folder we've specified is remembered so next time we'll generate DDL SQL scripts it will automatically pre-select this folder and the task will be valid immediately. - The task is now valid and we can perform it to produce the DDL SQL script. Click Perform Tasks.. to generate the DDL SQL script.
- Save your project, e.g. by pressing
Ctrl-S
.
Executing the script on the database server
The DDL SQL script we created in the previous section can now be used to create the catalog, schema, tables and constraints in the database server. For this tutorial we'll be using SQL Server and SQL Server Management Studio (SSMS) to execute the script.
- Start SSMS and connect to your SQL Server database server.
-
Select from the menu File -> Open -> File and navigate to the folder into which you generated the DDL SQL create script. Select it and click Open. The file has
as filename something like 'DDLSQL_CreateScript_
- -
SSMS will open the file in a tab and it's ready to use. You can alter whatever you want, e.g. change the database name or specify SQL Server specific settings. When
you're ready, press
Ctrl-E
to execute the script. -
Click in the Object Explorer the 'Databases' node below your server node and press
F5
to refresh them. You should now have a catalog with the name of your project, containing tables and foreign keys.
Next step
Now that we have a ready-to-use database and a proper entity model with mappings, we can generate code to use it in our program: Generate source code