views:

21

answers:

1

Suppose that I have 2 tables:

[User]
- UserID
- Username

[Task]
- TaskID
- TaskName
- TaskCreatedByUserID
- TaskAssignedToUserID

In the [Task] table, both of the ***UserID fields are foreign keys to the [User] table. So when I use the designer to create my LINQ models, I have access to 2 foreign [User] objects with property names: "User" and "User1". I'd like to give them more precise, meaningful names like "TaskCreatedByUser" and "TaskAssignedToUser" . I could, of course, go into the dbml.designer.cs file and change them, but then they will simply be overwritten the next time I have to alter the DB. Another option is to create a redundant property, but that seems silly. Is there a way to manually specify the foreign object property names in the designer (or otherwise) in a way that is persistent?

+1  A: 

Go into the designer, right click on the line that represents the association between the classes, and select properties. You can change the name of the child-collection property on the parent and the name of the parent property on the child.

The changes will be saved in the Association element in the dbml.

David B
Thank you very much David. For anyone else needing to do this, here's a more precise set of instructions: Right click on the arrowed-line representing the child/parent correlation. In the properties pane in the bottom right, you will see "Child Property" and "Parent Property". Depending on the one that you wish to rename, hit the + sign next to it and change the "Name" subfield.
Corey O.