Click here to Skip to main content
15,891,567 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I want to define a Foreign Key for one column in two Tables.

I am working in VWD 2010.

I tried "SELECT * FROM Employees INNER JOIN Departments ON (Employees.DepartmentID = Departments.ID);

That worked but when I add "ADO.net Entity Data Model" it did not show the Foreign Key Bridge between the two tables.

How do I get that bridge?
Posted
Updated 14-Jul-14 0:17am
v2
Comments
CHill60 14-Jul-14 7:00am    
Selecting from a pair of tables does not define a foreign key. How have you defined the foreign key?
arvind mepani 14-Jul-14 7:39am    
I agree with @CHill60, You have to add foreign key constraint in table by adding relationship between Employees and Department table, then update model from database.

1 solution

You need to do some research on Foreign Key Contraints[^]
Something like this might work
SQL
ALTER TABLE Employees
ADD CONSTRAINT FK_Department FOREIGN KEY (DepartmentID)
    REFERENCES Departments (ID) ;
 
Share this answer
 
Comments
Maciej Los 14-Jul-14 10:13am    
+5

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900