views:

75

answers:

2

Hi

I am just starting out with the Entity Framework and in my ms sql database I made a diagram in some relationships of tables have a primary key to primary key relation ship what I conceive as 1 to 1 relationship.

Now I generated EF database in VS2008 and these same ones have a relationship of 1 to 0..1

So it seems to say "0" or "1". I am not sure what this really means and if I should be correcting it to 1 to 1.

Thanks

A: 

0..1 means that in this table, there can be no entry with the same key as on the other side of the relation or at most one. Other conventions use the letter C to denote this (therefore called 1..C).

Changing it to 1..1 means that there always be exactly one entry in this table. In that case you could think about merging the tables into one.

Ralph Rickenbach
+5  A: 

0..1 effectively means "optional." There can be at most one value, but there may not be a value at all. Think of it like a nullable reference.

If you will always have a value there, it should be just 1 or 1..1.

Jon Skeet