ALTER TABLE VCLib.T_ReportFileGroup DROP CONSTRAINT FK_ReportFileGroup_Report;

ALTER TABLE VCLib.T_ReportFileGroup ADD CONSTRAINT FK_T_REPORT_T_REPORTFILEGROUP_ReportID
FOREIGN KEY("reportid") REFERENCES VCLib.T_Report (ReportID);

ALTER TABLE VCLib.T_PROCESS_ACCESS_ENTRY DROP CONSTRAINT FK_TPROCESS_AE_TENTITIES;

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);

ALTER TABLE VCLib.T_COMMAND DROP CONSTRAINT FK_T_ROOT_COMMAND_T_COMMAND_Owner;

ALTER TABLE VCLib.T_COMMAND ADD CONSTRAINT FK_T_COMMAND_T_COMMAND_Owner
FOREIGN KEY("owner") REFERENCES VCLib.T_COMMAND (CommandID);

ALTER TABLE VCLib.T_USER_COLUMNS DROP CONSTRAINT FK_TUSERCOLUMNS_USERCONTEXT;

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);

ALTER TABLE VCLib.T_USERS_ROLES DROP CONSTRAINT FK_ROLE_USERS;

ALTER TABLE VCLib.T_USERS_ROLES ADD CONSTRAINT FK_T_ROLES_T_USERS_ROLES_RoleID
FOREIGN KEY("roleid") REFERENCES VCLib.T_ROLES (RoleID);

ALTER TABLE VCLib.T_ENT_ATTR_ACCESS_ENTRY DROP CONSTRAINT FK_TENTITYATTR_AE_TENTITIES;

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);

ALTER TABLE VCLib.T_USER_SESSIONS DROP CONSTRAINT FK_SESSIONS_USER;

ALTER TABLE VCLib.T_USER_SESSIONS ADD CONSTRAINT FK_T_USERS_T_USER_SESSIONS_UserID
FOREIGN KEY("userid") REFERENCES VCLib.T_USERS (UserID);

ALTER TABLE VCLib.T_USER_CONTEXTS DROP CONSTRAINT FK_T_USER_CONTEXTS_ENTITY;

ALTER TABLE VCLib.T_USER_CONTEXTS ADD CONSTRAINT FK_T_ENTITIES_T_USER_CONTEXTS_EntityID
FOREIGN KEY("entityid") REFERENCES VCLib.T_ENTITIES (EntityID);

ALTER TABLE VCLib.T_ENTITY_ACCESS_ENTRY DROP CONSTRAINT FK_ENTRY_ENTITY;

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);

ALTER TABLE VCLib.T_Report DROP CONSTRAINT FK_T_REPORTS_T_ENTITIES2;

ALTER TABLE VCLib.T_Report ADD CONSTRAINT FK_T_ENTITIES_T_REPORT_EntityID
FOREIGN KEY("entityid") REFERENCES VCLib.T_ENTITIES (EntityID);

ALTER TABLE VCLib.T_USER_SEARCHES DROP CONSTRAINT FK_USER_SEARCH_ENTITY;

ALTER TABLE VCLib.T_USER_SEARCHES ADD CONSTRAINT FK_T_ENTITIES_T_USER_SEARCHES_EntityID
FOREIGN KEY("entityid") REFERENCES VCLib.T_ENTITIES (EntityID);

ALTER TABLE VCLib.T_ENTITIES ADD CONSTRAINT FK_T_ENTITIES_T_ENTITIES_BaseEntity
FOREIGN KEY("baseentity") REFERENCES VCLib.T_ENTITIES (EntityID);

ALTER TABLE VCLib.T_CHANGESETS DROP CONSTRAINT FK_TCHANGESETS_USERS;

ALTER TABLE VCLib.T_CHANGESETS ADD CONSTRAINT FK_T_USERS_T_CHANGESETS_UserId
FOREIGN KEY("userid") REFERENCES VCLib.T_USERS (UserID);

ALTER TABLE VCLib.T_USER_CONFIG DROP CONSTRAINT FK_USER_CFG;

ALTER TABLE VCLib.T_USER_CONFIG ADD CONSTRAINT FK_T_USERS_T_USER_CONFIG_UserID
FOREIGN KEY("userid") REFERENCES VCLib.T_USERS (UserID);