You can cheat from the already existsing templates.
For example check the EntityAdapter.template
You will find the following line:
<[Foreach RelatedEntity OneToOne CrLf]><[If Not MappedFieldRelationIsHidden]> private <[RelatedEntityName]>Entity _<[CaseCamel MappedFieldNameRelation]>;<[EndIf]><[NextForeach]>
Which defines the private member field mapped to a related entity. you can trace it's usage inside the template. (search for other places where "RelatedEntity" is used)
Also for FieldsOnRelatedFields, check the EntityIncludeAdapter.template
<[ Foreach RelatedEntityField CrLf]>
/// <summary> Gets <[ If Not IsReadOnly ]>/ Sets <[ EndIf ]>the value of the related field this.<[ MappedFieldNameRelation ]>.<[ RelatedEntityFieldName ]>.</summary>
public virtual <[If GenerateAsNullableType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]> <[ MappedFieldNameRelatedField ]>
{
get
{
<[RelatedEntityName]>Entity relatedEntity = this.<[ MappedFieldNameRelation ]>;
if(relatedEntity!=null)
{
return relatedEntity.<[ RelatedEntityFieldName ]>;
}
else
{
return (<[If GenerateAsNullableType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]>)TypeDefaultValue.GetDefaultValue(typeof(<[If GenerateAsNullableType]>Nullable<<[TypeOfField]>><[Else]><[TypeOfField]><[EndIf]>));
}
}
<[ If Not IsReadOnly ]> set
{
<[RelatedEntityName]>Entity relatedEntity = this.<[ MappedFieldNameRelation ]>;
if(relatedEntity!=null)
{
relatedEntity.<[ RelatedEntityFieldName ]> = value;
}
}<[ EndIf ]>
}<[ NextForeach ]>