{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3409","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3409/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3409/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3409/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3409","id":110957867,"number":3409,"title":"Query: ThenInclude throw ArgumentNullException when entity implements the interface","user":{"login":"Boglen","id":10594440,"avatar_url":"https://avatars.githubusercontent.com/u/10594440?v=3","gravatar_id":"","url":"https://api.github.com/users/Boglen","html_url":"https://github.com/Boglen","followers_url":"https://api.github.com/users/Boglen/followers","following_url":"https://api.github.com/users/Boglen/following{/other_user}","gists_url":"https://api.github.com/users/Boglen/gists{/gist_id}","starred_url":"https://api.github.com/users/Boglen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Boglen/subscriptions","organizations_url":"https://api.github.com/users/Boglen/orgs","repos_url":"https://api.github.com/users/Boglen/repos","events_url":"https://api.github.com/users/Boglen/events{/privacy}","received_events_url":"https://api.github.com/users/Boglen/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-12T11:44:02Z","updated_at":"2015-10-13T23:01:30Z","closed_at":"2015-10-13T23:01:29Z","body":"    public interface ITestEntity1\r\n    {\r\n        int Id { get; set; }\r\n\r\n        ICollection<ITestEntity2> EntityChilds { get; set; }\r\n    }\r\n\r\n    public interface ITestEntity2\r\n    {\r\n        int Id { get; set; }\r\n\r\n        ICollection<ITestEntity2> Childs { get; set; }\r\n\r\n        int? TestEntity1Id { get; set; }\r\n        ITestEntity1 ParentRef { get; set; }\r\n        int? TestEntity2Id { get; set; }\r\n        ITestEntity2 Parent { get; set; }\r\n    }\r\n\r\n    public class TestEntity11 : ITestEntity1\r\n    {\r\n        public int Id { get; set; }\r\n\r\n        public virtual ICollection<ITestEntity2> EntityChilds { get; set; }\r\n    }\r\n\r\n    public class TestEntity22 : ITestEntity2\r\n    {\r\n        public int Id { get; set; }\r\n\r\n        public virtual ICollection<ITestEntity2> Childs { get; set; }\r\n\r\n        public int? TestEntity1Id { get; set; }\r\n        public ITestEntity1 ParentRef { get; set; }\r\n        public int? TestEntity2Id { get; set; }\r\n        public ITestEntity2 Parent { get; set; }\r\n    }\r\n\r\n    public class TestContext22 : DbContext\r\n    {\r\n        public DbSet<TestEntity11> Entity1 { get; set; }\r\n        public DbSet<TestEntity22> Entity2 { get; set; }\r\n\r\n        protected override void OnModelCreating(ModelBuilder modelBuilder)\r\n        {\r\n            base.OnModelCreating(modelBuilder);\r\n            modelBuilder.HasAnnotation(\"SqlServer:ValueGenerationStrategy\", SqlServerValueGenerationStrategy.IdentityColumn);\r\n\r\n            modelBuilder.Entity<TestEntity11>(b => {\r\n                b.HasKey(k => k.Id);\r\n                b.HasMany(p => (ICollection<TestEntity22>)p.EntityChilds).WithOne(o => (TestEntity11)o.ParentRef).HasForeignKey(k => k.TestEntity1Id).IsRequired(false);\r\n            });\r\n\r\n            modelBuilder.Entity<TestEntity22>(b => {\r\n                b.HasKey(k => k.Id);\r\n                b.HasMany(p => (ICollection<TestEntity22>)p.Childs).WithOne(o => (TestEntity22)o.Parent).HasForeignKey(k => k.TestEntity2Id).IsRequired(false);\r\n            });\r\n        }\r\n}\r\n\r\n            using (var context = new TestContext22())\r\n            {\r\n                context.Database.EnsureDeleted();\r\n                context.Database.EnsureCreated();\r\n\r\n                var ent1 = context.Add(new TestEntity11()).Entity;\r\n                context.SaveChanges();\r\n\r\n                var ent21 = context.Add(new TestEntity22()).Entity;\r\n                var ent22 = context.Add(new TestEntity22()).Entity;\r\n                var ent23 = context.Add(new TestEntity22()).Entity;\r\n\r\n                context.SaveChanges();\r\n\r\n                ent21.ParentRef = ent1;\r\n                ent21.Childs = new List<ITestEntity2>() { ent22, ent23 };\r\n\r\n\r\n                context.SaveChanges();\r\n\r\n\r\n                //Throw exception\r\n                var getIt = context.Entity1.Include(p => p.EntityChilds).ThenInclude(i => i.Childs).ToList();\r\n            }\r\n"},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/147877997","html_url":"https://github.com/aspnet/EntityFramework/issues/3409#issuecomment-147877997","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3409","id":147877997,"user":{"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},"created_at":"2015-10-13T23:01:29Z","updated_at":"2015-10-13T23:01:29Z","body":"This is because mapping to interfaces is not supported. This means `public virtual ICollection<ITestEntity2> EntityChilds { get; set; }` is not a valid navigation property and so it is not included in the model - therefore you get an exception when you try to include it.\r\n\r\nEnabling this scenario with interfaces is already tracked by https://github.com/aspnet/EntityFramework/issues/757 "}}