Create this table in a Mysql Database:
CREATE TABLE `apibio` (
`id` TINYINT(4) UNSIGNED NOT NULL AUTO_INCREMENT,
`bid` VARCHAR(50) NOT NULL COLLATE 'utf8_general_ci',
`descr` VARCHAR(500) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`mesunit` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`dattyp` VARCHAR(50) NULL DEFAULT NULL COLLATE 'utf8_general_ci',
`act` TINYINT(4) NULL DEFAULT '1',
PRIMARY KEY (`id`) USING BTREE,
UNIQUE INDEX `bididx` (`bid`) USING BTREE
) COLLATE='utf8_general_ci' ENGINE=INNODB CHECKSUM=1 AUTO_INCREMENT=4;
Use the following class as exported from Aurelius:
[Entity]
[Table('apibio')]
[UniqueKey('bid')]
[Id('Fid', TIdGenerator.IdentityOrSequence)]
Tapibiometrics = class
private
[Column('id', [TColumnProp.Required, TColumnProp.NoInsert, TColumnProp.NoUpdate])]
Fid: Integer;
[Column('bid', [TColumnProp.Required], 50)]
Fbid: string;
[Column('descr', [], 500)]
Fdescr: Nullable<string>;
[Column('mesunit', [], 50)]
Fmesunit: Nullable<string>;
[Column('dattyp', [], 50)]
Fdattyp: Nullable<string>;
[Column('act', [])]
Fact: Nullable<Integer>;
public
property id: Integer read Fid write Fid;
property bid: string read Fbid write Fbid;
property descr: Nullable<string> read Fdescr write Fdescr;
property mesunit: Nullable<string> read Fmesunit write Fmesunit;
property dattyp: Nullable<string> read Fdattyp write Fdattyp;
property act: Nullable<Integer> read Fact write Fact;
end;
Update the table with the following code:
procedure TForm7.doupdate;
var DBM:TDatabaseManager;
begin DBM:=TDatabaseManager.Create(AureliusConnection1.CreateConnection,TMappingExplorer.Default);
try
dbm.SQLExecutionEnabled:=true;
dbm.UpdateDatabase;
finally DBM.free; end;
end;
Say goodbye to table's unique index.... What am I doing wrong?
dbm.Builddatabase does not help
Same happens with TColumnProp.unique
By the way, how can I set name of the index (like bididx in this example) from attributes mapping?