This is my second day with EntityFramework and I have another problem:
I'm saving some kind of configuration into my database. This works well: This is my class:
public class Configuration : IConfiguration {.... public ICollection<EmailClassificationPattern> emailClassificationPatterns { get; set; } ... } I get two tables dbo.Configurations and dbo.EmailClassificationPatterns. dbo.EmailClassificationPatterns has 4 entries and each references correctly to dbo.Configurations via a field called Configuration_ID.
I am loading the configuration this way:
var configuration = (Configuration)mycontext.Configurations.Where(x => x.configurationName=="Default").FirstOrDefault(); Then I am trying to access the member emailClassificationPatterns this was:
var relevantSubjectList = configuration.emailClassificationPatterns. Select( x => x.subjectPatternForMailCollection); But I get a ReferenceNullException because emailClassificationPatterns is NULL. Why does enttity framework not load the referenced members? I don't have the possibility to include the referenced member as IntelliSense doesn't provide .Inlcude() (like this:)
var configuration = (Configuration)mycontext.Configurations.Where(x => x.configurationName=="Default").Include("emailClassificationPattern") Do I HAVE to enable eagerLoading? If yes - how? Is there another way to access referenced members and is there some kind of best-practice?
Best regards
Sebastian