多重でリレーションしているテーブルをDBからコードを自動生成すると以下のように変なネーミングになってどのカラムとリレーションしているかわからなくなります(相手のテーブル名順)。
TableA.cs
using System;
using System.Collections.Generic;
public partial class TableA
{
.
.
.
public virtual TableB TableB { get; set; }
public virtual TableB TableB1 { get; set; }
public virtual TableB TableB2 { get; set; }
public virtual TableB TableB3 { get; set; }
}
ttファイルを以下のように変えると解消されるよ。
xxbefore.tt
// 50行目くらい
this.<#=code.Escape(navigationProperty)#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
// 200行目くらい
_code.Escape(navProp),
↓↓↓↓↓↓↓↓↓↓↓
xxafter.tt
// 50行目くらい
this.<#=code.Escape(navigationProperty.RelationshipType).Replace("_","")#> = new HashSet<<#=typeMapper.GetTypeName(navigationProperty.ToEndMember.GetEntityType())#>>();
// 200行目くらい
_code.Escape(navProp.RelationshipType).Replace("_",""),
ビバ、エドマックス!