0
다음과 같은 모델을 사용하고 있습니다. 먼저 Entity Framework 6 코드를 사용하여 응용 프로그램에서 사용하고 있습니다. 엔티티 프레임 워크 1 대 1 관계
public class Customer
{
public Customer
{
}
public int Id { get; set; }
public string Name { get; set; }
public virtual Address Address { get; set; }
}
public class Address
{
public Address
{
}
public int Id { get; set; }
public string Street { get; set; }
public int Number { get; set; }
public int Country { get; set; }
public virtual Customer Customer { get; set; }
}
내가 그들을 저장하려고
나는 다음과 같은 오류 얻을 :Unable to determine the principal end of an association between the types Customer and Address
그래, 그게 문제를 해결합니다. 고마워요! 한 가지 더 질문 : 유창한 API를 사용하여 달성 할 수 있다는 것을 읽었으며 고객 요청시 : HasRequired (c => c.Address) .WithRequiredPrincipal (a => a.Customer); 주소에 대해서도 똑같이하는 것입니까, 아니면 이것으로 충분합니까? 그리고 그것은 작동합니다 ... – user2818430
외래 키가있는쪽에 정의되어야합니다. 예를 들어, 주소와 고객 모두 외래 키를 저장 한 상태에서 양측에 있어야합니다. – pcreech