I've got lazy loading off, and proxy creation doesn't matter (tried both true and false, no difference).
I have this model:
public class Comment{
[Required]
public int SenderID { get; set; }
public User Sender { get; set; }
}
(and of course, I have a user class).
At database level, I confirm that the Sender is a valid User object. I have some IQueryable<Comment>
named commentsQuery
(that basically takes some comments from a post. Then I include the Sender navigation property and execute the query:
var comments = commentsQuery.Take(50).OrderBy(c => c.ID).Include(c => c.Sender).ToList();
However, some comment objects inside the list have their Sender
set to null even though I've explicitly included the navigation property.
If I turn on lazy loading it works correctly, but I don't want to turn on lazy loading.
Why is the explicitly-included required navigation property null? (I'm on Entity Framework 6.1.3)