{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6492","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6492/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6492/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6492/events","html_url":"https://github.com/aspnet/EntityFramework/issues/6492","id":175697650,"number":6492,"title":"Include of related collections are dropped when use Skip()","user":{"login":"m-anthoine","id":19952979,"avatar_url":"https://avatars.githubusercontent.com/u/19952979?v=3","gravatar_id":"","url":"https://api.github.com/users/m-anthoine","html_url":"https://github.com/m-anthoine","followers_url":"https://api.github.com/users/m-anthoine/followers","following_url":"https://api.github.com/users/m-anthoine/following{/other_user}","gists_url":"https://api.github.com/users/m-anthoine/gists{/gist_id}","starred_url":"https://api.github.com/users/m-anthoine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/m-anthoine/subscriptions","organizations_url":"https://api.github.com/users/m-anthoine/orgs","repos_url":"https://api.github.com/users/m-anthoine/repos","events_url":"https://api.github.com/users/m-anthoine/events{/privacy}","received_events_url":"https://api.github.com/users/m-anthoine/received_events","type":"User","site_admin":false},"labels":[{"id":403964217,"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/closed-fixed","name":"closed-fixed","color":"777777","default":false},{"id":421529701,"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/patch-approved","name":"patch-approved","color":"a37c0f","default":false},{"id":76481852,"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/type-bug","name":"type-bug","color":"f7c6c7","default":false}],"state":"closed","locked":false,"assignee":{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars.githubusercontent.com/u/1528107?v=3","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false},"assignees":[{"login":"smitpatel","id":1528107,"avatar_url":"https://avatars.githubusercontent.com/u/1528107?v=3","gravatar_id":"","url":"https://api.github.com/users/smitpatel","html_url":"https://github.com/smitpatel","followers_url":"https://api.github.com/users/smitpatel/followers","following_url":"https://api.github.com/users/smitpatel/following{/other_user}","gists_url":"https://api.github.com/users/smitpatel/gists{/gist_id}","starred_url":"https://api.github.com/users/smitpatel/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/smitpatel/subscriptions","organizations_url":"https://api.github.com/users/smitpatel/orgs","repos_url":"https://api.github.com/users/smitpatel/repos","events_url":"https://api.github.com/users/smitpatel/events{/privacy}","received_events_url":"https://api.github.com/users/smitpatel/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/22","html_url":"https://github.com/aspnet/EntityFramework/milestones/1.0.2","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/22/labels","id":2020064,"number":22,"title":"1.0.2","description":null,"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":0,"closed_issues":8,"state":"open","created_at":"2016-09-21T18:50:54Z","updated_at":"2016-11-03T19:01:41Z","due_on":null,"closed_at":null},"comments":15,"created_at":"2016-09-08T08:45:53Z","updated_at":"2016-11-17T17:37:14Z","closed_at":"2016-11-03T19:01:41Z","body":"Visual Studio 201 update 3\nAsp.net Core website project\nef7 : V1.0.0\npostgresql database : Npgsql.EntityFrameworkCore.PostgreSQL v1.0.0\n\nI have a context with some entities : \n\n```\n    public class CatalogueContext : IdentityDbContext<ApplicationUser>\n    {\n        public CatalogueContext(DbContextOptions<CatalogueContext> options)\n            : base(options)\n        {\n        }\n\n        protected override void OnModelCreating(ModelBuilder modelBuilder)\n        {\n            base.OnModelCreating(modelBuilder);\n\n            modelBuilder.Entity<ProduitCategorie>()\n                .HasKey(t => new { t.Produit_ProduitId, t.Categorie_CategorieId });\n\n            modelBuilder.Entity<ProduitCategorie>()\n                .HasOne(pt => pt.Produit)\n                .WithMany(p => p.ProduitCategories)\n                .HasForeignKey(pt => pt.Produit_ProduitId);\n\n            modelBuilder.Entity<ProduitCategorie>()\n                .HasOne(pt => pt.Categorie)\n                .WithMany(t => t.ProduitCategories)\n                .HasForeignKey(pt => pt.Categorie_CategorieId);\n        }\n\n        public DbSet<Famille> Familles { get; set; }\n        public DbSet<Categorie> Categories { get; set; }\n        public DbSet<Produit> Produits { get; set; }\n    }\n```\n\n```\n    public class Famille \n    {\n        public int FamilleId { get; set; }\n        [Required]\n        [MaxLength(250)]\n        public string Titre { get; set; }\n        public virtual ICollection<Categorie> Categories { get; set; }\n\n        public int OrdreAffichage { get; set; }\n\n        public Famille()\n        {\n            Categories = new List<Categorie>();\n        }\n    }\n\n```\n\n```\n    public class Categorie\n    {\n        public int CategorieId { get; set; }\n        [Required]\n        [MaxLength(250)]\n        public string Titre { get; set; }\n        public virtual ICollection<ProduitCategorie> ProduitCategories { get; set; }\n\n        [ForeignKey(\"Famille_FamilleId\")]\n        public virtual Famille Famille { get; set; }\n        [Required]\n        public int Famille_FamilleId { get; set; }\n\n        public int OrdreAffichage { get; set; }\n\n        public Categorie()\n        {\n            ProduitCategories = new List<ProduitCategorie>();\n        }\n    }\n```\n\n```\n    public class Produit\n    {\n        public int ProduitId { get; set; }\n        [Required]\n        [MaxLength(250)]\n        public string Titre { get; set; }\n\n        public string Description { get; set; }\n\n        public virtual ICollection<ProduitCategorie> ProduitCategories { get; set; }\n\n        public Produit()\n        {\n            ProduitCategories = new List<ProduitCategorie>();\n        }\n    }\n```\n\n```\n    public class ProduitCategorie\n    {\n\n        [Required]\n        public int Produit_ProduitId { get; set; }\n        [ForeignKey(\"Produit_ProduitId\")]\n        public Produit Produit { get; set; }\n\n\n        [ForeignKey(\"Categorie_CategorieId\")]\n        public Categorie Categorie { get; set; }\n        [Required]\n        public int Categorie_CategorieId { get; set; }\n\n        public ProduitCategorie()\n        {\n\n        }\n    }\n```\n\nWhen i try to get paged data of \"Produit\" entities, I get some troubles to include its related collection of \"ProduitCategorie\"s\n\n```\n    public class ProduitService : GenericRepository<Produit>, IProduitService\n    {\n        public ProduitService(CatalogueContext ctx) :\n            base(ctx)\n        {\n        }\n\n        public void Dispose()\n        {\n        }\n\n        public List<Produit> GetPagedData(int skip, int take)\n        {\n            CatalogueContext context = this.context; //injected by service layer constructor\n            List<Produit> data = null;\n\n            data = context.Produits.Skip(skip).Take(take).Include(c => c.ProduitCategories).ThenInclude(c => c.Categorie).ThenInclude(c => c.Famille).ToList();\n\n            return data;\n        }\n    }\n\n```\n\nWhen I call `GetPagedData(0, 10);` the 10th first element are returned with their `ProduitCategories` collection populated.\n\nWhen I call it with a skip value other than 0, the collection is always returned with 0 elements.\n\n![ef7](https://cloud.githubusercontent.com/assets/19952979/18342452/465493b0-75af-11e6-9ce5-b044e03ff021.png)\n\nMaybe it's relevant or not but even skip 0 or skip 10 produced the same output in debug window : \n\nskip(0) : \n\n```\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (0ms) [Parameters=[@__p_1='?', @__p_0='?'], CommandType='Text', CommandTimeout='30']\nSELECT \"p\".\"ProduitId\", \"p\".\"Description\", \"p\".\"ImagePath\", \"p\".\"Reference\", \"p\".\"Titre\"\nFROM \"Produits\" AS \"p\"\nORDER BY \"p\".\"ProduitId\"\nLIMIT @__p_1 OFFSET @__p_0\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (0ms) [Parameters=[@__p_1='?', @__p_0='?'], CommandType='Text', CommandTimeout='30']\nSELECT \"p0\".\"Produit_ProduitId\", \"p0\".\"Categorie_CategorieId\", \"c\".\"CategorieId\", \"c\".\"Famille_FamilleId\", \"c\".\"OrdreAffichage\", \"c\".\"Titre\", \"f\".\"FamilleId\", \"f\".\"OrdreAffichage\", \"f\".\"Titre\"\nFROM \"ProduitCategorie\" AS \"p0\"\nINNER JOIN \"Categories\" AS \"c\" ON \"p0\".\"Categorie_CategorieId\" = \"c\".\"CategorieId\"\nINNER JOIN \"Familles\" AS \"f\" ON \"c\".\"Famille_FamilleId\" = \"f\".\"FamilleId\"\nWHERE EXISTS (\n    SELECT 1\n    FROM \"Produits\" AS \"p\"\n    WHERE \"p0\".\"Produit_ProduitId\" = \"p\".\"ProduitId\"\n    LIMIT @__p_1 OFFSET @__p_0)\nORDER BY \"p0\".\"Produit_ProduitId\"\n```\n\nSkip(10) : \n\n```\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (0ms) [Parameters=[@__p_1='?', @__p_0='?'], CommandType='Text', CommandTimeout='30']\nSELECT \"p\".\"ProduitId\", \"p\".\"Description\", \"p\".\"ImagePath\", \"p\".\"Reference\", \"p\".\"Titre\"\nFROM \"Produits\" AS \"p\"\nORDER BY \"p\".\"ProduitId\"\nLIMIT @__p_1 OFFSET @__p_0\nMicrosoft.EntityFrameworkCore.Storage.Internal.RelationalCommandBuilderFactory:Information: Executed DbCommand (0ms) [Parameters=[@__p_1='?', @__p_0='?'], CommandType='Text', CommandTimeout='30']\nSELECT \"p0\".\"Produit_ProduitId\", \"p0\".\"Categorie_CategorieId\", \"c\".\"CategorieId\", \"c\".\"Famille_FamilleId\", \"c\".\"OrdreAffichage\", \"c\".\"Titre\", \"f\".\"FamilleId\", \"f\".\"OrdreAffichage\", \"f\".\"Titre\"\nFROM \"ProduitCategorie\" AS \"p0\"\nINNER JOIN \"Categories\" AS \"c\" ON \"p0\".\"Categorie_CategorieId\" = \"c\".\"CategorieId\"\nINNER JOIN \"Familles\" AS \"f\" ON \"c\".\"Famille_FamilleId\" = \"f\".\"FamilleId\"\nWHERE EXISTS (\n    SELECT 1\n    FROM \"Produits\" AS \"p\"\n    WHERE \"p0\".\"Produit_ProduitId\" = \"p\".\"ProduitId\"\n    LIMIT @__p_1 OFFSET @__p_0)\nORDER BY \"p0\".\"Produit_ProduitId\"\n\n```\n\nTo my tests, there are no problems when I try to include/thenInclude related entities that are not collections.\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/261314470","html_url":"https://github.com/aspnet/EntityFramework/issues/6492#issuecomment-261314470","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6492","id":261314470,"user":{"login":"Eilon","id":202643,"avatar_url":"https://avatars.githubusercontent.com/u/202643?v=3","gravatar_id":"","url":"https://api.github.com/users/Eilon","html_url":"https://github.com/Eilon","followers_url":"https://api.github.com/users/Eilon/followers","following_url":"https://api.github.com/users/Eilon/following{/other_user}","gists_url":"https://api.github.com/users/Eilon/gists{/gist_id}","starred_url":"https://api.github.com/users/Eilon/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Eilon/subscriptions","organizations_url":"https://api.github.com/users/Eilon/orgs","repos_url":"https://api.github.com/users/Eilon/repos","events_url":"https://api.github.com/users/Eilon/events{/privacy}","received_events_url":"https://api.github.com/users/Eilon/received_events","type":"User","site_admin":false},"created_at":"2016-11-17T17:37:14Z","updated_at":"2016-11-17T17:37:14Z","body":"In it's fair to assume that every RTM (i.e. non-pre-rel) version was released with all the fixes from all lower versions."}}
{"actor":{"display_login":"Eilon"}}