Automatic Primary Key Columns
DataFlex 25.0 makes it easier for developers to implement identity support in new database tables. The goal is to simplify the setup of a table and facilitate the quick creation of data entry and reporting applications.
When creating a new table in the Studio, a new option that creates a primary key column and sets the appropriate properties is available in the Create New Table dialog.

In the past, developers had to create the column, link it to a system table via the data dictionary class for the table, or find the ‘is identity’ table attribute in the properties dialog, followed by the creation of an index for the identity column.
The new option simplifies that process and is selected by default. When deselecting it, the old way of creating tables will revert to how it was in DataFlex version 24.0 and earlier.
Depending on the type of connection selected, the new creation process differs.
For MSSQL / Other
- A new integer column is created, named
[the_table_name]ID(e.g., for the tableCustomer, it will beCustomerID). - The
DF_FIELD_IS_IDENTITYattribute is set toTrue. - A primary key index is created for this new column.
For the Embedded Database
When Using a New Workspace
- A new table, named
DFLastID, is copied from theUsr\Newfolder to the workspace. It will use filelist slot number 270. - The new table dialog creates a numeric column, length 10, named
[the_table_name]ID(e.g., for the tableCustomer, it will beCustomerID). - An index is created for this column.
- A new column with the same name (
[the_table_name]ID) will be created in theDFLastIDtable if it does not yet exist. If that column already exists, developers will be prompted to decide if it should be used. If the answer is ‘No’, a digit will be appended to the column name (e.g.,CustomerID1), and the new name will be checked. This process will repeat, incrementing the digits until an appropriate column name is accepted. DFLastIDis checked to see if it is a system table; if not, the process will attempt to make it a system table. Note that if theDFLastIDtable already contains more than one record, it cannot be changed to a system table. A message will be displayed, and the column will not be added toDFLastID.- Upon saving the DataDictionary class file for the new table, the Studio saves the
DFLastIDtable, and the[Field_Auto_Increment](https://docs.dataaccess.com/dataflexhelp/mergedProjects/VdfClassRef/DataDictionary-Function-Field_Auto_Increment.md)option is set for the column in theDFLastIDtable. TheDFLastIDtable is automatically added to the list of externally updated tables.
When Using an Existing Workspace
- The new table dialog creates a numeric column, length 10, named
[the_table_name]ID(e.g., for the tableCustomer, it will beCustomerID). - An index is created for this column.
- The
DFLastIDtable will most likely not be present, and you might already have a system table in place. Therefore, you are responsible for adding thefield_auto_incrementoption for this new column in the DataDictionary class of your existing system table. - Developers who would like to switch to using the
DFLastIDtable may perform the following steps: - Go to the
USR\Newfolder. - Copy the
DFLastIDfiles (Data and DDSrc) to the workspace. - Add the
DFLastIDtable to the existing filelist (do not copy thefilelist.cfg) via the Table Explorer in the Studio, preferably using number 270 as the table number (theDFLastIDat a different number will still work). - Remap existing
field_auto_incrementrules to theDFLastIDtable. - Copy the contents of the current system table to
DFLastID. - Drop the old system table.