OneToMany relation does not use the correct parent key
Posted: Wed 20 Jan 2010 12:33
I have a class "ContractPartner" with three properties:
Id (int, primary key)
Name (string)
PartyId (int)
I want to create a one-to-many association with another class "Port". It has a property "PartyId" that indicates which ContractPartner it belongs to.
So I've created an association with ContractPartner as the parent class and Port as the child class, and I've chosen "PartyId" as both the parent and child property to use.
But when I run my program the relation is matched on "Id" on the parent class instead of "PartyId".
If I look in the generated code, the attributes for the association looks like this:
If I change it manually to this, it works just fine:
Now how do I get my Entity Developer (using version 2.50.50) to generate this for me?
Id (int, primary key)
Name (string)
PartyId (int)
I want to create a one-to-many association with another class "Port". It has a property "PartyId" that indicates which ContractPartner it belongs to.
So I've created an association with ContractPartner as the parent class and Port as the child class, and I've chosen "PartyId" as both the parent and child property to use.
But when I run my program the relation is matched on "Id" on the parent class instead of "PartyId".
If I look in the generated code, the attributes for the association looks like this:
Code: Select all
[Association(Name="ContractPartner_Port", Storage="_ContractPartner", ThisKey="PartyId", IsForeignKey=true)]
Code: Select all
[Association(Name="ContractPartner_Port", Storage="_ContractPartner", ThisKey="PartyId", OtherKey="PartyId")]