[BUG] No schema at foreign key references (v4.0.30)
Posted: Mon 22 Aug 2011 16:05
If I use a different database schema for my generated storage objects the sql scripting engine (for SQL Server 2008 in my case) forgets to add that schema in front of the table names in foreign key references.
Example:
While the schema 'ibi' is correctly added in front of 'tblKunden' for the CREATE statement, it is missing in front of 'tblPersonen' in the REFERENCES part at the end. So if my DB user doesn't have 'ibi' as its default schema, the script will fail because the DB can't find the table 'tblPersonen'.
The corrected script looks like that and runs fine:
Example:
Code: Select all
--
-- Creating a table ibi.tblKunden
--
CREATE TABLE ibi.tblKunden (
KN_PN_GUID UNIQUEIDENTIFIER NOT NULL,
KN_ID VARCHAR(MAX) NOT NULL,
CONSTRAINT PK_tblKunden PRIMARY KEY (KN_PN_GUID),
CONSTRAINT FK_tblKunden_tblPersonen_0 FOREIGN KEY (KN_PN_GUID) REFERENCES tblPersonen (PN_GUID)
The corrected script looks like that and runs fine:
Code: Select all
--
-- Creating a table ibi.tblKunden
--
CREATE TABLE ibi.tblKunden (
KN_PN_GUID UNIQUEIDENTIFIER NOT NULL,
KN_ID VARCHAR(MAX) NOT NULL,
CONSTRAINT PK_tblKunden PRIMARY KEY (KN_PN_GUID),
CONSTRAINT FK_tblKunden_tblPersonen_0 FOREIGN KEY (KN_PN_GUID) REFERENCES ibi.tblPersonen (PN_GUID)