0

Possible Duplicate:
1:1 relationship problems with EF Model First

Is there a way to define 1:1 relationships on a Entity Framework .edmx without get this annoying:

Error 1 Running transformation: Multiplicity is not valid in Role 'PESSOACPF' in relationship 'FK_CPF_PES'. Because the Dependent Role properties are not the key properties, the upper bound of the multiplicity of the Dependent Role must be *.

Already defined the FK as PK on my table, removed the pk, tried to re-create the project over 10 times and doesn't help AT ALL.

Community
  • 1
  • 1

1 Answers1

2

Your Foreign Key must be defined as UNIQUE.

To enforce a 1:0 or 1:1 relationship.

You can create Table in SQL DB like this (Lets take Order and OrderDetails Tables)):

CREATE TABLE OrderDetails (
    DetailsId INTEGER IDENTITY NOT NULL,
    orderId INTEGER NOT NULL UNIQUE,
    PRIMARY KEY (DetailsId),
    FOREIGN KEY (orderId) REFERENCES Order(orderId)
)

For more details Implementing one-to-zero-or-one relation in SQL Server

I hope this will help to you.

Community
  • 1
  • 1
Sampath
  • 63,341
  • 64
  • 307
  • 441