Entity Developer and generated Foreign Key Names

Discussion of open issues, suggestions and bugs regarding Entity Framework support in ADO.NET Data providers
Post Reply
pcrissman
Posts: 8
Joined: Mon 28 Sep 2009 13:16

Entity Developer and generated Foreign Key Names

Post by pcrissman » Tue 08 Dec 2009 21:50

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

skingaby
Posts: 32
Joined: Thu 14 May 2009 16:17

Post by skingaby » Wed 09 Dec 2009 03:53

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!

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Wed 09 Dec 2009 12:40

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.

smarti
Posts: 5
Joined: Tue 31 May 2011 19:30

Post by smarti » Tue 31 May 2011 19:43

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.

AndreyR
Devart Team
Posts: 2919
Joined: Mon 07 Jul 2008 13:16

Post by AndreyR » Thu 09 Jun 2011 16:12

We are investigating the possibility to add some functionality dealing with this situation.
I will let you know about the results of our investigation.

Post Reply