{"action":"closed","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3029","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3029/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3029/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3029/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3029","id":104983657,"number":3029,"title":"Projection with Count not generating correct SQL","user":{"login":"davezych","id":3639296,"avatar_url":"https://avatars.githubusercontent.com/u/3639296?v=3","gravatar_id":"","url":"https://api.github.com/users/davezych","html_url":"https://github.com/davezych","followers_url":"https://api.github.com/users/davezych/followers","following_url":"https://api.github.com/users/davezych/following{/other_user}","gists_url":"https://api.github.com/users/davezych/gists{/gist_id}","starred_url":"https://api.github.com/users/davezych/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davezych/subscriptions","organizations_url":"https://api.github.com/users/davezych/orgs","repos_url":"https://api.github.com/users/davezych/repos","events_url":"https://api.github.com/users/davezych/events{/privacy}","received_events_url":"https://api.github.com/users/davezych/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/bug","name":"bug","color":"f7c6c7"},{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/pri0","name":"pri0","color":"e11d21"}],"state":"closed","locked":false,"assignee":{"login":"maumar","id":1591930,"avatar_url":"https://avatars.githubusercontent.com/u/1591930?v=3","gravatar_id":"","url":"https://api.github.com/users/maumar","html_url":"https://github.com/maumar","followers_url":"https://api.github.com/users/maumar/followers","following_url":"https://api.github.com/users/maumar/following{/other_user}","gists_url":"https://api.github.com/users/maumar/gists{/gist_id}","starred_url":"https://api.github.com/users/maumar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maumar/subscriptions","organizations_url":"https://api.github.com/users/maumar/orgs","repos_url":"https://api.github.com/users/maumar/repos","events_url":"https://api.github.com/users/maumar/events{/privacy}","received_events_url":"https://api.github.com/users/maumar/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/17","html_url":"https://github.com/aspnet/EntityFramework/milestones/7.0.0-rc1","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/17/labels","id":1311414,"number":17,"title":"7.0.0-rc1","description":"","creator":{"login":"rowanmiller","id":4741851,"avatar_url":"https://avatars.githubusercontent.com/u/4741851?v=3","gravatar_id":"","url":"https://api.github.com/users/rowanmiller","html_url":"https://github.com/rowanmiller","followers_url":"https://api.github.com/users/rowanmiller/followers","following_url":"https://api.github.com/users/rowanmiller/following{/other_user}","gists_url":"https://api.github.com/users/rowanmiller/gists{/gist_id}","starred_url":"https://api.github.com/users/rowanmiller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rowanmiller/subscriptions","organizations_url":"https://api.github.com/users/rowanmiller/orgs","repos_url":"https://api.github.com/users/rowanmiller/repos","events_url":"https://api.github.com/users/rowanmiller/events{/privacy}","received_events_url":"https://api.github.com/users/rowanmiller/received_events","type":"User","site_admin":false},"open_issues":28,"closed_issues":97,"state":"open","created_at":"2015-09-17T20:13:31Z","updated_at":"2015-10-23T23:57:55Z","due_on":"2015-11-30T08:00:00Z","closed_at":null},"comments":21,"created_at":"2015-09-04T22:56:20Z","updated_at":"2015-10-23T23:57:55Z","closed_at":"2015-10-23T23:57:55Z","body":"I have a few forum style entities with references as such:\r\n\r\n    public class Forum\r\n    {\r\n        public int ForumId { get; set; }\r\n        public string Title { get; set; }\r\n\r\n        public ICollection<Topic> Topics { get; set; } =  new List<Topic>();\r\n    }\r\n\r\n    public class Topic\r\n    {\r\n        public int TopicId { get; set; }\r\n        public string Title { get; set; }\r\n\r\n        public int ForumId { get; set; }\r\n        public Forum Forum { get; set; }\r\n    }\r\n\r\n    public class MyContext : DbContext\r\n    {\r\n        public DbSet<Forum> Forums { get; set; }\r\n        public DbSet<Topic> Topics { get; set; }\r\n\r\n        protected override void OnModelCreating(ModelBuilder modelBuilder)\r\n        {\r\n            modelBuilder.Entity<Forum>()\r\n                        .Collection(f => f.Topics)\r\n                        .InverseReference(t => t.Forum)\r\n                        .ForeignKey(t => t.ForumId);\r\n        }\r\n    }\r\n\r\nI'm attempting to get a list of `Forum` with the count of the `Topic` for each forum:\r\n\r\n    return _context.Forums.Include(f => f.Topics).Select(f => new\r\n            {\r\n                Title = f.Title,\r\n                TopicCount = f.Topics.Count(),\r\n            });\r\n\r\nThis results in the following SQL:\r\n\r\n    SELECT [f].[ForumId], [f].[Title]\r\n    FROM [Forums] AS [f]\r\n\r\nand doesn't include a `Count` aggregate or anything, and returns 0 Topics. Is this a bug, or is this type of projection not supported?"}}