2

I am currently generating some code from an edmx file with a t4 template by going through all of the properties. By default the edmx file has navigation properties that are named after the object type essentially but I would like to change it to work off of the foreign key id column instead.

For example there is a Region table which is referred to by a single table twice - it has both a Supervisory Region and a Geographic Region. The default edmx navigation property name is Region and Region1 which isn't very descriptive. I would like the regions to be called SupervisoryRegion and GeographicRegion instead.

I would normally go into the edmx and rename these navigation properties but little things in the database change all the time and the edmx file doesn't "update" very gracefully without pulling in the database again which clears my renames.

Any help would be greatly appreciated...

jfritz
  • 21
  • 2
  • It's three years and two versions later (VS 2013), and this issue is still there. – JamesQMurphy Feb 13 '15 at 17:18
  • For those looking for answers to this, head over to: http://stackoverflow.com/questions/12937193/improve-navigation-property-names-when-reverse-engineering-a-database/13064383#13064383 – Arkiliknam Feb 17 '17 at 14:42

2 Answers2

2

No it is not possible to change convention for naming navigation properties.

Thanks @Arkiliknam for comment. Someone else found a way to do that: Improve navigation property names when reverse engineering a database

Community
  • 1
  • 1
Ladislav Mrnka
  • 360,892
  • 59
  • 660
  • 670
  • It looks possible to me, as detailed in http://stackoverflow.com/questions/12937193/improve-navigation-property-names-when-reverse-engineering-a-database/13064383#13064383 – Arkiliknam Feb 17 '17 at 14:43
1

Just noticed this question on my right hand bar - I have just posted an answer to what is actually the same question (despite the title) here:

What T4 file is used to generate an EDMX from database via “Update Model From Database”?

Esssentially my solution is to prewash the EDMX using a T4 template to fix up these badly named navigation properties.

Community
  • 1
  • 1
James Close
  • 862
  • 9
  • 15