Ok... I give up...
I've been searching this forum and staring at the docs and code for a couple of hours now trying to figure this out.
In Template Studio, using the C# templates, how can I get the name of the related field from a given EntityRelation.
<%
foreach(EntityRelation rel in Entity.Relations)
{
if(rel.RelationType == EntityRelationType.OneToMany && !rel.UtilizingPropertyIsHidden)
{
if (Entity.PrimaryKeyFields.Count == 1) {
string primaryKeyName = ((EntityFieldDefinition)Entity.PrimaryKeyFields[0]).FieldName;
string foreignKeyName = ((EntityFieldDefinition)Entity.PrimaryKeyFields[0]).MappedField.FieldName;
%>
in the above code: primaryKeyName and foreignKeyName are always the same... (the PK) Am I missing something?
I need to name of the FK field in the related table...