Meaningful Names for Navigation Properties using Entity Framework

前端 未结 3 1202
臣服心动
臣服心动 2020-12-10 13:39

I am using the ADO .NET Entity Framework to import my model from a database. A table in my db has a bunch of foreign keys, all with abstract names e.g. FKDevice132610

相关标签:
3条回答
  • 2020-12-10 13:55

    As I know there is currently no way to do that. This is how current designer works. What is even worse when you rename these properties to correct names updating model from database will sometimes overwrite your changes.

    Improvement of navigation property naming is tracked by this work item - http://entityframework.codeplex.com/workitem/125

    0 讨论(0)
  • 2020-12-10 14:05

    Wondering if a search on "modelBuilder.Conventions.Remove" will lead you to a solution. I wish I could be more of a help but I am just starting to explore EF. Ran into a similar situation when I had multiple fields referring back to the same ID...and I do not remember what the work around was.

    0 讨论(0)
  • 2020-12-10 14:05

    Four years later...
    Until the EF team solves this issue, one possible workaround could be to parse the .edmx file using an external tool and replace all texts starting with <NavigationProperty Name= by more meaningful navigation names.
    Being XML, is extremely easy to parse and find properties like multiplicity, FK name, etc.

    0 讨论(0)
提交回复
热议问题