How to Rename Navigation poperty via .edmx [ef db first] RRS feed

  • Question

  • I generated an .edmx file and edited the Entity template (DbName.tt) to generate friendly names for the navigation properties. A simple example:

    • Entity NavigationProperty1 becomes Entity ParentNavigationProperty
    • ICollection NavigationProperties2 becomes ICollection SubNavigationProperties

    In the above example I removed the unnecessary numbers and added an extra word.

    This all works, but now my .edmx file won't update those navigation properties and because of that Entity Framework throws the following error for every Navigation poperty that was updated:

    Schema specified is not valid. Errors: 
    The relationship 'DBModel.FK_dbo_Entity1_dbo_Entity2_ID' was not loaded because the type 'DBModel.Entity2' is not available.
    The following information may be useful in resolving the previous error:
    The required property 'NavProp' does not exist on the type 'Entity2'.

    What I already have tried

    • Deleting and re-adding the entities/tables
    • Running Custom Tool
    • Regenerating .edmx

    But none of the above did work. Manually renaming the navigation properties in the .edmx works, but that's a lot of work...

    Is there an easy way to rename the navigation properties in the .edmx?

    Thanks in advance!

    Friday, October 23, 2015 1:54 AM


  • Hi Tonny Gu,
    According to this case, as far as I know, that  not have any easy way to rename the

    navigation properties in the edmx.

    The  original way is that you can rename the Navigation properties in the database.

    Then regenerating .edmx.

    Best Regards,


    Friday, October 23, 2015 7:44 AM