ALTER TABLE [VCLib].[T_ReportFileGroup] DROP CONSTRAINT [FK_ReportFileGroup_Report]
GO

ALTER TABLE [VCLib].[T_ReportFileGroup] ADD CONSTRAINT [FK_T_REPORT_T_REPORTFILEGROUP_ReportID]
FOREIGN KEY([ReportID]) REFERENCES [VCLib].[T_Report] ([ReportID])
GO

ALTER TABLE [VCLib].[T_PROCESS_ACCESS_ENTRY] DROP CONSTRAINT [FK_TPROCESS_AE_TENTITIES]
GO

ALTER TABLE [VCLib].[T_PROCESS_ACCESS_ENTRY] ADD CONSTRAINT [FK_T_ENTITIES_T_PROCESS_ACCESS_ENTRY_EntityID]
FOREIGN KEY([EntityID]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_COMMAND] DROP CONSTRAINT [FK_T_ROOT_COMMAND_T_COMMAND_Owner]
GO

ALTER TABLE [VCLib].[T_COMMAND] ADD CONSTRAINT [FK_T_COMMAND_T_COMMAND_Owner]
FOREIGN KEY([Owner]) REFERENCES [VCLib].[T_COMMAND] ([CommandID])
GO

ALTER TABLE [VCLib].[T_USER_COLUMNS] DROP CONSTRAINT [FK_TUSERCOLUMNS_USERCONTEXT]
GO

ALTER TABLE [VCLib].[T_USER_COLUMNS] ADD CONSTRAINT [FK_T_USER_CONTEXTS_T_USER_COLUMNS_UserContextID]
FOREIGN KEY([UserContextID]) REFERENCES [VCLib].[T_USER_CONTEXTS] ([UserContextID])
GO

ALTER TABLE [VCLib].[T_USERS_ROLES] DROP CONSTRAINT [FK_ROLE_USERS]
GO

ALTER TABLE [VCLib].[T_USERS_ROLES] ADD CONSTRAINT [FK_T_ROLES_T_USERS_ROLES_RoleID]
FOREIGN KEY([RoleID]) REFERENCES [VCLib].[T_ROLES] ([RoleID])
GO

ALTER TABLE [VCLib].[T_ENT_ATTR_ACCESS_ENTRY] DROP CONSTRAINT [FK_TENTITYATTR_AE_TENTITIES]
GO

ALTER TABLE [VCLib].[T_ENT_ATTR_ACCESS_ENTRY] ADD CONSTRAINT [FK_T_ENTITIES_T_ENT_ATTR_ACCESS_ENTRY_EntityID]
FOREIGN KEY([EntityID]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_USER_SESSIONS] DROP CONSTRAINT [FK_SESSIONS_USER]
GO

ALTER TABLE [VCLib].[T_USER_SESSIONS] ADD CONSTRAINT [FK_T_USERS_T_USER_SESSIONS_UserID]
FOREIGN KEY([UserID]) REFERENCES [VCLib].[T_USERS] ([UserID])
GO

ALTER TABLE [VCLib].[T_USER_CONTEXTS] DROP CONSTRAINT [FK_T_USER_CONTEXTS_ENTITY]
GO

ALTER TABLE [VCLib].[T_USER_CONTEXTS] ADD CONSTRAINT [FK_T_ENTITIES_T_USER_CONTEXTS_EntityID]
FOREIGN KEY([EntityID]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_ENTITY_ACCESS_ENTRY] DROP CONSTRAINT [FK_ENTRY_ENTITY]
GO

ALTER TABLE [VCLib].[T_ENTITY_ACCESS_ENTRY] ADD CONSTRAINT [FK_T_ENTITIES_T_ENTITY_ACCESS_ENTRY_EntityID]
FOREIGN KEY([EntityID]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_Report] DROP CONSTRAINT [FK_T_REPORTS_T_ENTITIES2]
GO

ALTER TABLE [VCLib].[T_Report] ADD CONSTRAINT [FK_T_ENTITIES_T_REPORT_EntityID]
FOREIGN KEY([EntityID]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_USER_SEARCHES] DROP CONSTRAINT [FK_USER_SEARCH_ENTITY]
GO

ALTER TABLE [VCLib].[T_USER_SEARCHES] ADD CONSTRAINT [FK_T_ENTITIES_T_USER_SEARCHES_EntityID]
FOREIGN KEY([EntityID]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_ENTITIES] ADD CONSTRAINT [FK_T_ENTITIES_T_ENTITIES_BaseEntity]
FOREIGN KEY([BaseEntity]) REFERENCES [VCLib].[T_ENTITIES] ([EntityID])
GO

ALTER TABLE [VCLib].[T_CHANGESETS] DROP CONSTRAINT [FK_TCHANGESETS_USERS]
GO

ALTER TABLE [VCLib].[T_CHANGESETS] ADD CONSTRAINT [FK_T_USERS_T_CHANGESETS_UserId]
FOREIGN KEY([UserId]) REFERENCES [VCLib].[T_USERS] ([UserID])
GO

ALTER TABLE [VCLib].[T_USER_CONFIG] DROP CONSTRAINT [FK_USER_CFG]
GO

ALTER TABLE [VCLib].[T_USER_CONFIG] ADD CONSTRAINT [FK_T_USERS_T_USER_CONFIG_UserID]
FOREIGN KEY([UserID]) REFERENCES [VCLib].[T_USERS] ([UserID])
GO