I have a parent entity and a child entity.
In the DB the primary key for parent is p_p_id
and the foreign key in the child is the same p_p_id
There is no foreign key constraint in the database.
The entities have the properties set up in their respective classes pointing at each other.
Parent Class
public virtual ChildProject ThisChildProject { get; set; }
Child Class
public virtual ParentProject ThisParentProjection { get; set; }
There are no annotations on these properties nor on the Ids of either class.
In the config, I tried to do the mapping in the child.
HasRequired(i => i.ThisParentProject).WithOptional(o => o.ThisChildProject );
What happens is EF tries to map using the primary key of the child and the primary key of the parent.
But I want to use a defined FK in the child and the primary key of the parent
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…