Page 1 of 1

Entity Developer and generated Foreign Key Names

Posted: Tue 08 Dec 2009 21:50
by pcrissman
Hi,
We are using Entity Developer to generate our Entity Framework model. We have a database with numerous tables, all of which have common fields Created_By and Modified_By that are foreign keys to a table named User_Info. When we generate the model, we end up with class properties for these as UserInfo and UserInfo1. Unfortunately it is very difficult to tell which one is the CreatedBy and which one is the Modified by. It is not consistent from table to table, and seems it had to do with the order in which the Foreign Keys were defined. It therefore makes it extremely difficult to implement any common logic around these fields.

1). Is there a way to have the code generated not use names such as UserInfo and UserInfo1 and use something like CreatedByUserInfo and ModifiedByUserInfo? Can this be done in a fashion that is not manual? We have so many tables and constantly changes that it is much easier for us to regenerate our model from scratch and not have to worry about manual changes.

2). If we can't change the names easily, is there anyway for it to not base on the order of the foreign keys? most people setting up tables should not be worrying about the order of the FK's (this typically would never matter)

Pam Crissman

Posted: Wed 09 Dec 2009 03:53
by skingaby
I second this. We have a Supplier table with a FK to Contact for the Sales Contact and the Shipping Contact. These get generated as Contact and Contact1 and the few times I have had to add these two tables to the model, it is not obvious which is which at all. Thanks!

Posted: Wed 09 Dec 2009 12:40
by AndreyR
Thanlk you for the report, we will investigate the issue.
I will let you know about the results of our investigation.

upd: I have deleted your duplicate entry.

Posted: Tue 31 May 2011 19:43
by smarti
Is there any update on this? We really use this tool on any database that will go into production when the foreign keys have names like ID1, ID2. Escpecially if there are multiple foreign keys.

This seems like something not hard to change. Just take the name of the parent Table, and add ID, or something of the like.

I can likely fix this be changing all my Primary Keys to instead of having 'ID' as their key to be 'ID' for a name... but a pain.

Posted: Thu 09 Jun 2011 16:12
by AndreyR
We are investigating the possibility to add some functionality dealing with this situation.
I will let you know about the results of our investigation.