2012-12-27 3 views
0

나는 오후 내내 이것을 풀려고 노력했지만 비어있게되었습니다. 우리의 스키마가 옳은 것처럼 보이지는 않지만 그것을 변경할 권한이 없습니다.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; } 
} 

답변

0

경우 당신은 사파리 온라인 계정 http://my.safaribooksonline.com/book/-/9781449317867에서 줄리 러먼에서이 책은 매우 유용

자선 객체는 것 같습니다.

여기에 예제와 같이 네비게이션 속성이없는 외래 키에 관한 줄리 (Julie)의 무료 기사가 있습니다. 그것은 가능하지만 작업하기가 더 어렵습니다.

http://msdn.microsoft.com/en-us/magazine/ee532098.aspx?sdmr=JulieLerman&sdmi=authors 외래 키가없는 상태로 만들기 란을 참조하십시오.

관련 문제