2012-04-24 12 views
2

私はいくつかの子エンティティそうのような熱心な負荷にしようとしているが:イーガーロードEntity Frameworkのナビゲーションプロパティのエラー

_context.Sites.Where(x => x.ID == siteID).Include(s => s.SiteLoggers).FirstOrDefault(); 

しかし、私は取得していますエラーは次のとおりです。

A specified Include path is not valid. The EntityType 'MyProject.Dal.EF.Site' does not declare a navigation property with the name 'SiteLoggers'. 

何を言っているがMyProject.Dal.EF.Siteが存在しないため、オブジェクトはMyProject.Domain.Entities.Siteに存在します。

私は何が欠けていますか?ありがとう!

POCOS:

namespace MyProject.Domain.Entities 
{ 
    public class Site 
    { 
     public int ID { get; set; } 
     public int LocationID { get; set; } 
     public bool Active { get; set; } 
     public bool Deleted { get; set; } 
     public string Name { get; set; } 
     public virtual Location Location { get; set; } 
     public virtual IEnumerable<SiteLogger> SiteLoggers { get; set; } 
    } 
} 

namespace MyProject.Domain.Entities 
{ 
    public class SiteLogger 
    { 
     public int ID { get; set; } 
     public int UID { get; set; } 
     public int SiteID { get; set; } 
     public string Name { get; set; } 
     public int LocationID { get; set; } 
     public bool Active { get; set; } 
     public bool Deleted { get; set; } 
     public virtual Site Site { get; set; } 
     public virtual Location Location { get; set; } 
    } 
} 

答えて

3

あなたはEFがあなたのナビゲーションプロパティがICollection<T>.

public virtual ICollection <SiteLogger> SiteLoggers { get; set; } 
+0

グレートのように定義されている必要がありますので、ICollection代わりのIEnumerableを使用する必要があります!ありがとう!それはあまりにも奇妙な行動を説明するでしょう!半日を過ごす前にまずネットに乗っていたはずです。 – Matt

関連する問題