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?
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.