views:

54

answers:

1

Hi,

I am using LINQ To SQL to handle data access in a project. For a case where I have multiple foreign keys in a table to the same table (for e.g. CustomerUserId, TechnicianUserId) , it generates the property names like ApplicationUser and ApplicationUser1. Is there a way to tweak the code generator to produce easier to read names.

I was pleasently surprised by LINQPad in this regard. It correctly generates property names (for e.g. in this case CustomerUser and TechnicianUser).

+1  A: 

If you use the LINQ2SQL designer, you can select the connection between the two classes and modify the property names (expand Child Property and/or Parent Property in your properties window).

Ronald Wildenberg
Ya but this is usually not a practical approach. The changes are overridden when i need to synchronize the model with the schema changes :(
Ali Kazmi
Agreed that this is not a practical approach. I haven't found a good solution for it yet...
Ronald Wildenberg
Maybe you could take a look at http://www.olegsych.com/2009/01/t4-toolbox-linq-to-sql-classes-generator/
Ronald Wildenberg