Create DDL SQL Update Script
To export the 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 adjusted on the database server as well. This tutorial guides you through these steps.
Generating an Update 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 Update script from the changed 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 Update Script (DDL SQL). Alternatively you can do this too from the Catalog Explorer or by selecting from the menu Project -> Generate Database Schema Update 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 update the database schema 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 Update script. Select it and click Open. The file has
as filename something like 'DDLSQL_UpdateScript_
- -
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 new table Employee, and Order should have a new field 'RequiredDate' as well as a new foreign key constaint.
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