Join the Stack Overflow Community
Stack Overflow is a community of 6.5 million programmers, just like you, helping each other.
Join them; it only takes a minute:
Sign up

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; }

    }
}

See, the collection isn't loaded!

Important! This does work with eager loading, but i want to use lazy loading, can anybody help me?

share
    
Do you have lazy loading disabled? – CodingYoshi 7 secs ago

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.