0
엔티티와 코드를 먼저 사용하여 외래 키 관계를 추가하려고합니다. 다음 간단한 설정이 있습니다.엔티티가 외래 키를 생성합니다.
public class ChildClass
{
public int SId { get; set; }
[ForeignKey("SId")]
public ParentClass Parent { get; set; }
}
public class ParentClass
{
[Key]
public int SId { get; set; }
public ChildClass Child { get; set; }
}
마이그레이션을 추가하려고하면 다음과 같은 오류가 발생합니다. 당신이 FK 약동학 될뿐만 아니라 당신의 ChildClass
에 SId
속성을 원하는 경우
Unable to determine the principal end of an association between the types 'ChildClass' and 'ParentClass'. The principal end of this association must be explicitly configured using either the relationship fluent API or data annotations.
' "에 ParentClass"를 넣어 시도는'대신' "SId를 '의' –
은 주석이 declarartion 이상이어야 안 있습니까? –