views:

693

answers:

2

Hi,

If I have a table with two foreign key fields to another table, I.E.

Table: User 
Field: FK_PrimaryItem_ID
Field: FK_SecondaryItem_ID

Table: Item 
Field: ItemID

When I'm using the entity framework, the generated objects become:

User.Item and User.Item1

and I can't differentiate between the two of them. I can map back to the name of the foreign key, but this is a difficult way to go about it. How can I find out which one, Item1 or Item is which field?

I would like to leave my EDMX file auto generating if possible.

+2  A: 

I've not found any problems with updating my model once I'd changed the name of the Navigation Properties on the design surface.

In general, User.Item would be represent the first column the model came to with that foreign key, and User.Item1 would represent the second column.

But as I said, I just went into the model, and changed the name of the Navigation Properties to more usable names based on the association listed in the Mapping Details.

Zhaph - Ben Duguid
Thanks, I was afraid this would be my only option. We have had trouble with updates, especially when you delete columns or rename them, but we'll just have to work around them I guess.
Odd
+1  A: 

I had the same problem with a self-referencing key:

PageID
Parent_PageID  (refers to PageID)

Until I renamed the Navigation Properties to "Parent" and "Children" respectively. The toughest part was figuring out which is which, which I did by noting the Multiplicity property on the NavigationProperty objects (0..1 for parent, * for children)

Kelly Adams