I have two tables. One is Request and the other is Response. Each request has a nullable foreign key reference to aResponse record.
Each Response record has a non-nullable foreign key reference to the Request entry that it came from.
I’m trying to generate the entities for this model and it fails validation with the error: Multiplicity is not valid in role Response [...]. Because the dependent role properties are not the key properties, the upper bound of the multiplicity of the dependent role must be *.
The mapping that fails:
Request -[0..1]-> Response
Response -[1]-> Request
Why doesn’t this work? I know EF doesn’t like foreign keys much, but this seems simple enough.
If have two tables and you want to model scenario where:
You are modelling single relation and you need only FK in response because request in this case is principal entity of the relation. FK on both sides would be needed if you want to model two independent relations.
To make this relation simply use
ResponseIdinResponseentity as FK toRequestIdinRequestentity (EF makes one-to-one relations on primary keys because it doesn’t support unique constraint at the moment).