Consider this simplified model:
public class Field
{
public string Name { get; set; }
public MultilingualString Label { get; set; }
public MultilingualString Placeholder { get; set; }
}
public class MultilingualString
{
public string DefaultText { get; set; }
public IList<Globalization> Globalizations { get; set; }
}
public class Globalization
{
public string Text { get; set; }
public Language Language { get; set; }
}
public class Language
{
public string Name { get; set; }
public string CultureString { get; set; }
}
Using my context, I am trying to get all my fields and include their Label and Placeholder along with the globalizations and language (the whole thing) by using the following command:
var field = context.Fields
.Include(x => x.Label.Globalizations)
.ThenInclude(x => x.Language)
.Include(x => x.Placeholder.Globalizations)
.ThenInclude(x => x.Language)
.ToList();
I get the following exception thrown:
System.InvalidOperationException Invalid attempt to read when no data is present.
However, using only the first include/theninclude, I do get the expected results.
What gives? Is this a known bug, or did I misunderstand the Include/ThenInclude syntax?
This is using ef7 beta4 with VS2015 RC