나는 오후 내내 이것을 풀려고 노력했지만 비어있게되었습니다. 우리의 스키마가 옳은 것처럼 보이지는 않지만 그것을 변경할 권한이 없습니다.Entity Framework 코드 첫 번째 엔터티 가상 탐색 속성없이 분할?
dbo.Charity
Id (PK, int, not null)
Name (varchar(100), not null)
dbo.CharityCountry
CharityId (PK, FK, int, not null)
CountryId (PK, FK, int, not null)
dbo.Country
Id (PK, int, not null)
Name (varchar(100), not null)
와 EF 모델로 얻을 :
는 기본적으로 나는이 세 테이블을 결합해야
그러나 기사의 대부분은이 작업을 수행하는 방법을 떠날 것 때문에 나는 완전히 혼란 스러워요 매핑 클래스 :
public class CharityMap : EntityTypeConfiguration<Charity>
{
public CharityMap()
{
this.HasKey(t => t.Id);
this.ToTable("dbo.Charity");
this.Property(t => t.Id).HasColumnName("Id");
this.Property(t => t.Name).HasColumnName("Name");
...
}
}
내가 알아야 할 것은에 넣어 것입니다 ... 나는 외래 키가 존재하지 프랑스 인 합성 엔티티 관계를 매핑하는 방법을 잘 모르겠습니다 om 기본 엔터티.
public class Charity
{
public int? Id { get; set; }
public string Name { get; set; }
public Country Country { get; set; }
}
그리고 국가 개체 :
public class Country
{
public int? Id { get; set; }
public string Name { get; set; }
}