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?
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.
Check this : SQL Server Database Design with a One To One Relationship