Question

I need to add a navigation property between two Entities TableA and TableB

TableA

ID : Primary Key 

Code: String (Allows Null)

TableB

BID:  Primary Key

Code: String (Allows Null)

Now I want to add a navigation property to these Entities which are related by the code which is not a foreign key. Can anyone tell me how this is possible

Was it helpful?

Solution

It is not possible because code is not PK in any of your tables. Navigation properties follows same rules as database relations - in principal table you must use PK and in dependent you specify FK. Databases also offers selecting unique key in principal table but EF doesn't support unique keys yet.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top