Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

Created Feature: Foreign Key Naming [6]

$
0
0
From Terry:
Take this example of two tables.
• Users
• Locations

Foreign key relationships
• Users.Location_FK_Locations_ID = Locations.ID
• Locations.Owner_FK_Users_ID = Users.ID

This results in ambiguous field names in the generated user class.
• User class

Has a Foreign key field called 'Location1' and a Reverse navigation field ‘Location’, not much use.

Can you possibly change the way you are naming these fields from being the table name, to a composite of table name and foreign key field name.

i.e.

The User class has a foreign key field called Location and Reverse navigation field called LocationsOwners.

Derived by...

The foreign key table's field name is a substring from index 0 to the first underscore.
• Location_FK_Locations_ID => “Location”

The Reverse navigation field is a combination of the foreign key table name + "_" + the foreign key table's associated FK field name where the name part is a substring of the string preceding the first underscore.

• Locations.Owner_FK_Users_ID => “Locations” + ”Owner “ + “s”


Viewing all articles
Browse latest Browse all 1642

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>