Some foreign key constraints on custom entity tables are missing after you upgrade to Microsoft Dynamics CRM 4.0
Consider the following scenario. You have a custom entity table, and the custom entity table has a primary key constraint and a foreign key constraint on the same column. When you upgrade to Microsoft Dynamics CRM 4.0, the foreign key constraint is removed during the upgrade process.
For example, assume that you have a custom entity table that is called AuditTrailExtensionBase. The following foreign key is added.
ALTER TABLE [dbo].[<databasename>_AuditTrailExtensionBase] ADD CONSTRAINT [FK_<databasename>_AuditTrailExtensionBase_<Databasename>_AuditTrailBase] FOREIGN KEY ([<databasename>_AuditTrailId]) REFERENCES [dbo].[<databasename>_AuditTrailBase] ([<databasename>_AuditTrailId])
After the upgrade process is complete, this foreign key is no longer present.
To resolve this problem, add the missing foreign key constraint to the custom entity table.
(source: http://support.microsoft.com/kb/947061)