Quick Objects Documentation Akal Tech Logo
Updating Classes When Underlying Database Schema Changes (v3.x)

Glossary Item Box

 Please note this tutorial is only application to v3.x. If you are still using v2.x please use this tutorial. We highly recommend that you switch to v3.x as this process is greatly simplified.  The steps from the v2.x still work in the current v3.x.

Often, database application developers come across situations where they are asked to implement an enhancement or change and it requires a database schema change. This sort of a chance can have a big impact on any application. If the business logic of the application is split into stored procedures, business logic layer and/or other layers then thats even a bigger challenge for the developers to figure out the impact of the underlying database schema modifications.

Quick Objects - Business Logic Framework is designed with this problem in mind and also to facilitate development of applications with fast changing requirements. The following tutorial shows how to keep the business logic layer's entity classes in sync with the database schema. Regenerating the classes to match with the database schema has the advantage of finding all the affects of the schema modification at the compile time and not having to spend countless hours on testing and re-testing application on every single modification.

Starting v3.x of the Quick Objects Designer application allows you to preserve your customizations during such refresh cycles. For example, if you changed certain field's AllowSave property and later refreshed the schema, the field will be considered a customized field and its properties will be preserved during the refresh cycle. 

Let us start the Quick Objects Designer program (Available under the Start -> All Programs -> Akal Tech - Quick Objects V3 menu).

Quick Objects Designer v3.x
EnlargeClick to enlarge
 
Then open the QO_SHOP.qos file located at {Program Files}\Akal Tech\Quick Objects V3\NET20\Samples\Database folder. The file shipped with the Quick Objects samples has the schema of the database shipped with the samples. To open an existing .qos file use the "Project" -> "Load From File" menu option.
Open the QO_SHOP.qos file
EnlargeClick to enlarge
 
This will load the schema information already saved in the QO_SHOP.qos file including the code generation options and output paths.

EnlargeClick to enlarge
 
If you have already made changes to the database schema you can skip the following steps that are only meant to highlight the fact that we changed the database schema.  We will add two columns to store an "Email" and a boolean value of "IsSubscribed" into Customer table for this scenario. You can virtually add/modify/remove columns/tables/relationships as you desire.
Making Schema Modifications
EnlargeClick to enlarge
 
Now lets refresh the Schema into the Quick Objects Designer. The steps are very simply, from the Project menu simply choose the "Refresh From Database". The fields, tables you added will not be checked (used) by default, and hence you will need to check them manually so that they are included in the code generation.  This is by design to ensure that you don't end up including unwanted tables or fields.
 
After the refresh cycle is complete, the new fields we added should show up in the schema. Now if we want to include them in our generated code all we need to do is simple check them. If we don't check them, they will not be included in the generated code.
 
Now you can save the project from Project -> Save menu.  After saving you can re-generate your base classes by choosing the Generate -> ("Base C# Classes" or "Base VB.NET Classes")