나는 Parent
및 Child
클래스/테이블이 있으며 Fluent API를 사용하여 매핑을 구성하고 있습니다. 테이블은 각 테이블의 기본 키가 아닌 필드에서 조인됩니다. 따라서 읽은 항목에 따라 Entity Framework에서 조인을 구성 할 수 없습니다. 그렇기 때문에 직접 Parent.Children
속성을로드 할 것입니다. (parent.Children = (from x in context.Children...
)매핑되지 않은 하위 엔터티가있는 오류
그러나 Parent
의 매핑에 대한 예외가 발생합니다. 내가 context.Parents
를 조회 할 때 내 수업은 내가 엔티티 프레임 워크가 생성하는 SQL은 Child
에 Parent
에 가입하려고하고 Child_ParentPrimaryKey
라는 Child
의 속성을 찾고 있기 때문에 예외가,
public class Parent
{
// Unique primary key
public int ParentPrimaryKey { get; set; }
// These two fields together compose the foreign key to join to Child
public string ParentForeignKey1 { get; set; }
public string ParentForeignKey2 { get; set; }
public List<Child> Children { get; set; }
}
public class Child
{
// Unique primary key
public int ChildPrimaryKey { get; set; }
// These two fields together compose the (non-unique) foreign key to join to Parent
public string ChildForeignKey1 { get; set; }
public string ChildForeignKey2 { get; set; }
}
처럼 보인다.
내가 modelBuilder.Entity<Parent>().Ignore(p => p.Children);
을 추가하면 나는 오류를받지 않고 System.NotSupportedException: The specified type member 'Packages' is not supported in LINQ to Entities. Only initializers, entity members, and entity navigation properties are supported.
가 어떻게 Parent
에 매핑되지 않은 속성으로 Children
을 유지할 수있는 예외거야?
이 경우 '무시'가 작동해야합니다. 나는 매핑이 괜찮으며 오류가 쿼리에 있다고 생각합니다. 'NotSupportedException'는 쿼리에서 매핑되지 않은 컬렉션 탐색 속성 인'Packages'를 사용하고있는 것처럼 보이며 지원되지 않습니다. 사용중인 전체 쿼리를 표시 할 수 있습니까? –
고맙습니다. @ V. 레온! 이 문제는 나를 미치게 만들었고 귀하의 의견은 문제를 지적했습니다. 내 쿼리에'Children' 탐색 속성을 사용하고있었습니다. 나는 그것을 제거하고, 지금 일하고있다. –