You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Sep 30, 2024. It is now read-only.
If a foreign key references two columns, the generated code is not valid. The code generated by ssc creates two alter table statements as follows:
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID('[dbo].[FK_CR BCG_CR BCD]') AND parent_object_id = OBJECT_ID('[dbo].[CR BCG]'))
BEGIN
ALTER TABLE [dbo].[CR BCG] WITH NOCHECK ADD CONSTRAINT [FK_CR BCG_CR BCD] FOREIGN KEY ([NRLIGNE]) REFERENCES [dbo].[CR BCD] ([COMPTEUR]) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE [dbo].[CR BCG] CHECK CONSTRAINT [FK_CR BCG_CR BCD]
END
IF NOT EXISTS (SELECT 1 FROM sys.foreign_keys WHERE object_id = OBJECT_ID('[dbo].[FK_CR BCG_CR BCD]') AND parent_object_id = OBJECT_ID('[dbo].[CR BCG]'))
BEGIN
ALTER TABLE [dbo].[CR BCG] WITH NOCHECK ADD CONSTRAINT [FK_CR BCG_CR BCD] FOREIGN KEY ([NRFACTURE]) REFERENCES [dbo].[CR BCD] ([NRFACTURE]) ON DELETE CASCADE ON UPDATE CASCADE
ALTER TABLE [dbo].[CR BCG] CHECK CONSTRAINT [FK_CR BCG_CR BCD]
END
Expected behavior
The code generated should recreate the foreign key. The code to create such a foreign key could look like (code generated by MS SQL Server Management Studio 2008 R2):
ALTER TABLE [dbo].[CR BCG] WITH NOCHECK ADD CONSTRAINT [FK_CR BCG_CR BCD] FOREIGN KEY([NRLIGNE], [NRFACTURE])
REFERENCES [dbo].[CR BCD] ([COMPTEUR], [NRFACTURE])
ON UPDATE CASCADE
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[CR BCG] CHECK CONSTRAINT [FK_CR BCG_CR BCD]
GO
The text was updated successfully, but these errors were encountered:
Describe the Issue
If a foreign key references two columns, the generated code is not valid. The code generated by ssc creates two alter table statements as follows:
Expected behavior
The code generated should recreate the foreign key. The code to create such a foreign key could look like (code generated by MS SQL Server Management Studio 2008 R2):
The text was updated successfully, but these errors were encountered: