private string CreateDatabaseColumn(TableManager tm, string tableName, FormFieldInfo updatedFieldInfo) { updatedFieldInfo.PrimaryKey = IsPrimaryField; string errorMessage = null; if (IsMainForm && !updatedFieldInfo.IsDummyField && !updatedFieldInfo.IsExtraField) { // Validate the default value string newDBDefaultValue = GetDefaultValueInDBCulture(updatedFieldInfo, out errorMessage, !DevelopmentMode); if (String.IsNullOrEmpty(errorMessage)) { switch (mMode) { case FieldEditorModeEnum.ClassFormDefinition: case FieldEditorModeEnum.BizFormDefinition: case FieldEditorModeEnum.SystemTable: case FieldEditorModeEnum.CustomTable: // Add new column to specified table if (!updatedFieldInfo.External && (tm != null)) { // Set column type and size string newColumnType = DataTypeManager.GetSqlType(updatedFieldInfo.DataType, updatedFieldInfo.Size, updatedFieldInfo.Precision); tm.AddTableColumn(tableName, updatedFieldInfo.Name, newColumnType, updatedFieldInfo.AllowEmpty, newDBDefaultValue, !DevelopmentMode); // Recreate the table PK constraint if (IsPrimaryField) { // Existing primary keys var pkFields = FormInfo.GetFields(true, true, true, true); // Include the new field in the collection pkFields.Add(updatedFieldInfo); var primaryKeys = pkFields.Select(pk => String.Format("[{0}]", pk.Name)); tm.RecreatePKConstraint(tableName, primaryKeys.ToArray()); } } break; } } } return errorMessage; }