I have three tables in my database:
- Post
- Author
- Tags
I'm using ASP.NET MVC 4 with EF 5 and my Post model (generated automatically) looks like this one:
public partial class BlogPost
{
public BlogPost()
{
this.Tags = new HashSet<Tag>();
}
...
public virtual Author Author { get; set; }
public virtual ICollection<Tag> Tags { get; set; }
}
My context and dbSet are definded. I'm trying to get all the posts in the database with this query
dbSet.ToList()
I thought that Author will be null and Tags will be empty, because I didn't use Include()
to use eager loading. But if I debug, I found that Author isn't null and Tags got two elements. I don't understand why.
In Tag entity I got a navigation property to get all the posts that got that Tag. It looks like is filling all the data... but I don't notice any performance problem when I test the page, it load very fast.
Maybe it's not an error... am I just missing something?