This behavior comes from the laziness of loading entities.
By default, you have to manually load each of sub-entity. It is called eager-loading.
In order to eager-load your entities, you have to use the .Include()
method on each of your navigation properties.
e.g. context.User.Include(x => x.Groups)
The Include method generates a new SQL statement to retrieve your Groups from database.
Then you can use the ToList()
method to force executing your query.