Reputation: 13402
I have a database table called "item" that has a self-referencing field called "itemParentID". When I generate an EDMX and models, I gain access to to "item.item1", which is the parent of the current item and "item.items1", which is a collection of child items. I also have the property "item.itemParentID", but I rarely use it directly.
How do these names "item1" and "items1" get chosen? I generate the EDMX from database and would like for the names to automatically be "topic.Parent" and "topic.Children" so that I would not have to touch the generated code or create additional code in partials.
Upvotes: 0
Views: 118
Reputation: 364249
That is the logic hardcoded into EDMX generation. The name is inferred from the name of related entity type but it doesn't work very well in case of self referencing relations or multiple relations to to the same type. In such cases the generator will add those numbers to property names.
The only way you can do to fix it is to rename properties in the designer but beware that this is also the only modification which is sometimes lost during updating the model from database.
Upvotes: 1
Reputation: 24383
Select the properties in your model ( edmx ) designer and open the properties window.
You can set the names there.
I don't know of a way of changing the names that are automatically generated.
Upvotes: 0