다음 DB 관계에 대한 Entity Framework 4.1 코드 첫 번째 모델을 작성하는 데 어려움이 있습니다.Entity Framework 4.1 코드에서 동일한 테이블을 가리키는 여러 개의 외래 키
다음은 관계를 시각적으로 나타낸 것입니다.
dbo. [회사]는 판매자 또는 채무자 중 하나를 회사 유형으로 사용할 수 있습니다.
dbo [SellerDebtors]는 판매자 회사가 Debtor Company와의 연결을 정의합니다.
작성한 코드는 원래 EF 4.0 POCO 모델 코드를 기반으로 작성되었습니다. 이것이 내가 생각해 낸 것입니다.이 코드는 작동하지 않습니다. 순간
public class SellerDebtor
{
public int SellerDebtorId { get; set; }
public int DebtorCompanyId { get; set; }
public int SellerCompanyId { get; set; }
public Company DebtorCompany { get; set; }
public Company SellerCompany { get; set; }
public ICollection<SellerDebtorInfo> SellerDebtorInfos { get; set; }
public ICollection<SellerDebtorFile> SellerDebtorFiles { get; set; }
}
public class Company
{
public int CompanyId { get; set; }
public string CompanyType { get; set; }
public string Name { get; set; }
public virtual ICollection<User> Users { get; set; }
public virtual ICollection<CompanyInfo> CompanyInfos { get; set; }
public virtual ICollection<CompanyFile> CompanyFiles { get; set; }
public virtual ICollection<SellerDebtor> SellerDebtorDebtorCompanies { get; set; }
public virtual ICollection<SellerDebtor> SellerDebtorSellerCompanies { get; set; }
}
, 내가 오류로 받고 있어요 :
System.Data.SqlClient.SqlException: Invalid column name 'DebtorCompany_CompanyId'.
Invalid column name 'SellerCompany_CompanyId'.
Invalid column name 'Company_CompanyId'.
Invalid column name 'Company_CompanyId1'.
를 이상적으로, 나는 관계의 이름을 유지할 수 있도록하고 싶습니다.
나는 몇 가지 속성을 설정해야한다고 추측하지만 설정해야 할 항목이 확실하지 않습니다.
[엔티티 프레임 워크 코드 첫 번째 - 두 개의 외래 키 같은 테이블]의 사용 가능한 복제 (http://stackoverflow.com/questions/5559043/entity-framework-code-first-two- foreign-keys-from-same-table) –