Wrapping navigation properties in Entity Framework 4
Say I have a database table Node
.
The开发者_开发知识库 table contains (among other attributes) the ParentID
attribute which is a self-referencing FK.
Entity Framework model created from such database table contains two navigational properties:
EntityCollection<Node> Node1
Node Node2
The names are confusing so I changed the names in the designer.
The problem with the approach is that the designer will overwrite my changes when updating the same class.
What I'd like to do is create the partial classes (in another file) that would basically wrap the mentioned navigation properties:
public EntityCollection<Node> ChildrenNodes
{
get
{
return Node1;
}
set
{
Node1 = value;
}
}
public Node ParentNode
{
get
{
return Node2;
}
set
{
Node2 = value;
}
}
Now, I can recreate the EDMX from scratch and my properties will remain.
However, what I am not sure about is whether this will break the Entity Framework. I don't know how much EF accesses by the name, so I am not sure what would be the consequences of such action.
Would this work normally or would it create some problems?
精彩评论