0

I have this class in EF 6 and I am generating code from it using T4 templates.

public partial class LocationState
{
    public LocationState()
    {
    }

    public int LocationStateID { get; set; }
    public Nullable<int> LocationCountryID { get; set; }
    public string Name { get; set; }
    public string Abbreviation { get; set; }

    public virtual LocationCountry LocationCountry { get; set;}
}

From within a T4 template I can identify LocationCountry as a navigation property of the object. However, I'd like to pull out only the fields which are not keys, and LocationCountryID is considered a primitive type. How do I identify LocationCountryID as a key field? The Edm properties for LocationCountry do not seem to have the key field associated with them.

thanks,

john

John Mott
  • 445
  • 6
  • 12
  • I belive key (or KeyMembers) is a property of the entity type, not a property of the property. – bricelam Sep 06 '14 at 15:28
  • Thank you bricelam, that will return the primary key, not key fields which are associated with object members of the class. The wizards that Visual Studio uses to create a scaffold for EF editing seem to know how to do it. – John Mott Sep 06 '14 at 17:03

1 Answers1

0

This question was answered in the post below. To be fair I really did search first before posting but it wasn't until I got into the edmx and saw that the 'association' tag was what I wanted that I was able to find the answer. Hopefully this post will act as another entry point to the answer.

Access Association Details of NavigationProperty

Community
  • 1
  • 1
John Mott
  • 445
  • 6
  • 12