{"action":"closed","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3483","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3483/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3483/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3483/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3483","id":112336404,"number":3483,"title":"502.3 Bad Gateway Error when using eager loading on a large dataset","user":{"login":"maxmantz","id":6616421,"avatar_url":"https://avatars.githubusercontent.com/u/6616421?v=3","gravatar_id":"","url":"https://api.github.com/users/maxmantz","html_url":"https://github.com/maxmantz","followers_url":"https://api.github.com/users/maxmantz/followers","following_url":"https://api.github.com/users/maxmantz/following{/other_user}","gists_url":"https://api.github.com/users/maxmantz/gists{/gist_id}","starred_url":"https://api.github.com/users/maxmantz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maxmantz/subscriptions","organizations_url":"https://api.github.com/users/maxmantz/orgs","repos_url":"https://api.github.com/users/maxmantz/repos","events_url":"https://api.github.com/users/maxmantz/events{/privacy}","received_events_url":"https://api.github.com/users/maxmantz/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-20T10:28:52Z","updated_at":"2015-10-20T18:33:11Z","closed_at":"2015-10-20T18:33:11Z","body":"Hi,\r\n\r\nI don't know whether this is an issue with EF or Web API (using Beta8).\r\nI have a classic many-to-many relationship set up like this:\r\n\r\n    public class Student {\r\n      public int Id { get; set; }\r\n      public string Name { get; set; }\r\n     \r\n     // many-to-many mapper\r\n     [JsonIgnore]  \r\n     public virtual ICollection<StudentCourse> StudentCourses { get; set; }\r\n    \r\n     // to be filled by eager loading\r\n     public virtual ICollection<Course> Courses { get; set; }\r\n    }\r\n\r\n    public class Course {\r\n       public int ID { get; set; }\r\n       public string Name { get; set; }\r\n       \r\n       [JsonIgnore]\r\n       public virtual ICollection<StudentCouse> StudentCourses { get; set; }\r\n       public virtual ICollection<Student> Students { get; set; }\r\n    }\r\n\r\n    public class StudentCourse {\r\n      public int StudentId { get; set; }\r\n      public Student Student { get; set; }\r\n      public int CourseId { get; set; }\r\n      public Course Course { get; set; }\r\n    }\r\n\r\nMy StudentsController has the following Get-Method:\r\n\r\n    [HttpGet]\r\n    public async Task<ActionResult> Get(bool lazy = true) {\r\n      ICollection<Student> students;\r\n      if (lazy) {\r\n         // this works fine\r\n         students = await ctx.Students.ToListAsync();\r\n      }\r\n      else {\r\n        // get all the data from the SQL server\r\n        students = await ctx.Students.Include(s => s.StudentCourses).ThenInclude(s => s.Course).ToListAsync();\r\n       // and map them to the Courses collection\r\n       foreach (var student in students) {\r\n         student.Courses = student.StudentCourses.Select(s => s.Course).ToList();\r\n       }\r\n      }\r\n    return Ok(students);\r\n    }\r\n\r\nWhile lazy loading works fine, I get the 502.3 error when using the eager loading method. There are no exceptions thrown to the console and when I'm debugging the eager loading process, everything works fine up until the `return Ok(students);` statement. The data has the correct format in memory, just doesn't get processed correctly.\r\nThe dataset I'm using is quite large though, so could this be an issue with the size of the returned data?"}}