これがあるとしましょう
class A
{
[Key]
public int Id { get; set; }
public string X { get; set; }
public string Y { get; set; }
public B B;
}
class B
{
[Key]
public int Id { get; set; }
public string X { get; set; }
public string Y { get; set; }
public virtual ICollection<A> As { get; set; }
}
X と Y のペアが B で一意であることが保証されていると仮定すると、{X, Y} は B の複合主キーになる可能性がありますが、そうではありません。
この偽の外部キー関係を介して AB がナビゲーション プロパティであることを Fluent API で表現することは可能ですか?
動作しないことを除いて、次のようなものです。
HasRequired(a => a.B).WithMany(b => b.As).HasForeignKey(a => new { a.X, a.Y })