Is there any way to change the Navigation Property name convention when an edmx is generated in Visual Studio 2010 to use the foreign key column name?

六月ゝ 毕业季﹏ 提交于 2019-12-20 02:58:19

问题


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...


回答1:


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




回答2:


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.



来源:https://stackoverflow.com/questions/8568835/is-there-any-way-to-change-the-navigation-property-name-convention-when-an-edmx

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!