I am using 3.5.10.4 and the model was made from the scratch. here is an example code from the generated DDL script. As you can see the IDENTITY keyword is used at the foreign key column as well and should only be used at the primary key
CREATE TABLE [LegalEntity]
(
[PK_LegalEntity] Bigint IDENTITY NOT NULL,
[FK_LegalEntity] Bigint IDENTITY NULL,
[AK_LegalEntity] Varchar(32) NOT NULL,
[LegalEntityName] Varchar(32) NOT NULL,
[EK_LegalEntityType] Varchar(32) NOT NULL,
[AddressLine1] Varchar(64) NULL,
[AddressLine2] Varchar(64) NULL,
[ZipCode] Varchar(16) NULL,
[City] Varchar(32) NULL,
[Country] Varchar(32) NULL,
[Website] Varchar(128) NULL,
[GroupID] Varchar(32) NULL,
[CommercialRegistryID] Varchar(32) NULL,
[TaxID] Varchar(32) NULL,
[ValueAddedTaxID] Varchar(32) NULL,
[Phone1] Varchar(32) NULL,
[Phone2] Varchar(32) NULL,
[Fax] Varchar(32) NULL,
[Email] Varchar(128) NULL
)
go
– Create indexes for table LegalEntity
CREATE INDEX [LegalEntity_FK_LegalEntity] ON [LegalEntity] ([FK_LegalEntity])
go
– Add keys for table LegalEntity
ALTER TABLE [LegalEntity] ADD CONSTRAINT [PK_LegalEntity] PRIMARY KEY NONCLUSTERED ([PK_LegalEntity])
go
ALTER TABLE [LegalEntity] ADD CONSTRAINT [LegalEntity_AK_LegalEntity] UNIQUE ([AK_LegalEntity])
go
I think I know the reason for that behaviour. I made an own Domain Type for the primary keys with the Identifier option, so I can use the same data type for all of my primary keys. of course the foreigh key columns should have the same data type so the same domain. but that makes no sense to me to create IDENTITY keyword on columns, that are not signed as a primary key.
I could assign the IDENTITY on table layer, but would be more nice to do it at the domain definition layer. And then it would be nice to check, if I have a primary key or a foreign key and use the IDENTITY keyword only for priamry keys.
Ilja
Message was edited by: Ilja