How to Create a real one-to-one relationship in SQL Server

James picture James · Apr 24, 2012 · Viewed 154.5k times · Source

I have two tables tableA and tableB, I set tableB's primary key as foreign key which references tableA's primary. But when I use Entity Framework database-first, the model is 1 to 0..1.

How does one create a one-to-one relationship in SQL Server?

Answer

Pranay Rana picture Pranay Rana · Apr 24, 2012

Set the foreign key as a primary key, and then set the relationship on both primary key fields. That's it! You should see a key sign on both ends of the relationship line. This represents a one to one.

enter image description here

Check this : SQL Server Database Design with a One To One Relationship