简体   繁体   中英

Database Diagram not showing table relation when new foreign key reference is added in SSMS 20114

I have three tables as follows -

在此处输入图片说明

But when I add the foreign key reference, the relation is ( a straight line in the Database Diagram) not shown .

Following is the reference I wrote.

ALTER TABLE [dbo].EmployeeDesignation   
ADD CONSTRAINT FK_EmployeeDesignation_Employee FOREIGN KEY (EmployeeId)     
    REFERENCES Employee (EmployeeId)     
    ON DELETE CASCADE    
    ON UPDATE CASCADE    
;

ALTER TABLE [dbo].[EmployeeDesignation]     
ADD CONSTRAINT FK_EmployeeDesignation_Designation FOREIGN KEY (DesignationId)     
    REFERENCES Designation (DesignationId)     
    ON DELETE CASCADE    
    ON UPDATE CASCADE    
;

In addition, When I add another two tables ( Department and EmployeeDepartment ) I can see the relation in the diagram 在此处输入图片说明

The code for the reference is as follows --

ALTER TABLE [dbo].EmployeeDepartment     
ADD CONSTRAINT FK_EmployeeDepartment_Department FOREIGN KEY (DepartmentId)     
    REFERENCES Department (DepartmentId)     
    ON DELETE CASCADE    
    ON UPDATE CASCADE    
;

ALTER TABLE [dbo].EmployeeDepartment     
ADD CONSTRAINT FK_EmployeeDepartment_Employee FOREIGN KEY (EmployeeId)     
    REFERENCES Employee (EmployeeId)     
    ON DELETE CASCADE    
    ON UPDATE CASCADE    
;

What might be the reason That the later one showing relation line while the previous one is not showing? Am I missing something?

Thanks !

Try closing SSMS and then reopening it again. Seems like the cache used by SSMS for some of functionality is not refreshed even upon closing and re-opening the database connection. check https://stackoverflow.com/a/4316415/364084

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM