I'm working with Entity Framework, and i've never had any problems with lazy loading, until now! I don't know why BUT this isn't working. Here is a couple of code snippets:
Under here the Entity PC. A PC hold a collection of SCANS.
namespace SnapshotTool.BO.Entities.SCEPEntities
{
public class PC
{
public PC()
{
Scans = new List<Scan>();
}
[Key]
public int ID { get; set; }
public string Name { get; set; }
public virtual ICollection<Scan> Scans { get; set; }
}
}
Under ere the SCAN Class:
namespace SnapshotTool.BO.Entities.SCEPEntities
{
public class Scan
{
protected Scan()
{
}
public int ID { get; set; }
public string Creator { get; set; }
public DateTime TimeStarted { get; set; }
public DateTime TimeFinished { get; set; }
public int ScanTypeID { get; set; }
public int StatusID { get; set; }
public int PCID { get; set; }
[ForeignKey("ScanTypeID")]
public virtual ScanType ScanType { get; set; }
[ForeignKey("StatusID")]
public virtual Status Status { get; set; }
[ForeignKey("PCID")]
public virtual PC PC { get; set; }
}
}
Important! This does work with eager loading, but i want to use lazy loading, can anybody help me?