{"action":"created","issue":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1462","repository_url":"https://api.github.com/repos/AutoMapper/AutoMapper","labels_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1462/labels{/name}","comments_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1462/comments","events_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1462/events","html_url":"https://github.com/AutoMapper/AutoMapper/issues/1462","id":164084293,"number":1462,"title":"Issue with null child objects with EF Core","user":{"login":"maganuk","id":15894292,"avatar_url":"https://avatars.githubusercontent.com/u/15894292?v=3","gravatar_id":"","url":"https://api.github.com/users/maganuk","html_url":"https://github.com/maganuk","followers_url":"https://api.github.com/users/maganuk/followers","following_url":"https://api.github.com/users/maganuk/following{/other_user}","gists_url":"https://api.github.com/users/maganuk/gists{/gist_id}","starred_url":"https://api.github.com/users/maganuk/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/maganuk/subscriptions","organizations_url":"https://api.github.com/users/maganuk/orgs","repos_url":"https://api.github.com/users/maganuk/repos","events_url":"https://api.github.com/users/maganuk/events{/privacy}","received_events_url":"https://api.github.com/users/maganuk/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":13,"created_at":"2016-07-06T14:08:32Z","updated_at":"2016-07-06T17:09:19Z","closed_at":null,"body":"I'm the midst of trying to upgrade an EF6 / ASP.Net (Automapper 4) application to EF Core (Automapper 5).\r\n\r\nWhat used to work was:\r\n```\r\npublic class Parent\r\n{\r\n    public int ID { get; set; }\r\n    public string ParentTitle { get; set; }\r\n    public int? ChildObjectID { get; set; }        //BREAKING CHANGE\r\n    public Child ChildObject { get; set; }\r\n}\r\n\r\npublic class Child\r\n{\r\n    public int ID { get; set; }\r\n    public string ChildTitle { get; set; }\r\n}\r\n\r\npublic class ChildDTO\r\n{\r\n    public int ID { get; set; }\r\n    public string ChildTitle { get; set; }\r\n}\r\n\r\npublic class ParentChildDTO\r\n{\r\n    public int ID { get; set; }\r\n    public string ParentTitle { get; set; }\r\n    public ChildDTO Child { get; set; }\r\n}\r\n```\r\nIn our configuration we would do:\r\n```\r\ncfg.CreateMap<Child, ChildDTO>();\r\ncfg.CreateMap<Parent, ParentChildDTO>();\r\n```\r\nWe would do:\r\n\r\n`Query.ProjectTo<ParentChildDTO>()` on an `IQueryable<Parent>` and it would all work like magic. If the child object was null then `ParentChildDTO.Child` would be null.\r\n\r\nNow with Automapper 5 and EF Core the same code gives an Argument types do not match exception.\r\n\r\nThis also happens if you are trying to map an ICollection of objects which is empty. (Value cannot be null exception).\r\n\r\nWhat works is `.MapFrom(c=>c.ChildID ! = null ? c.Child : null)`. But we have about 500 mappings and it would be a no go to do this for each and every mapping.\r\n\r\nI have also tried to get the nightly build to no avail.\r\n\r\nAny suggestions? Thanks"},"comment":{"url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/comments/230839575","html_url":"https://github.com/AutoMapper/AutoMapper/issues/1462#issuecomment-230839575","issue_url":"https://api.github.com/repos/AutoMapper/AutoMapper/issues/1462","id":230839575,"user":{"login":"jbogard","id":104498,"avatar_url":"https://avatars.githubusercontent.com/u/104498?v=3","gravatar_id":"","url":"https://api.github.com/users/jbogard","html_url":"https://github.com/jbogard","followers_url":"https://api.github.com/users/jbogard/followers","following_url":"https://api.github.com/users/jbogard/following{/other_user}","gists_url":"https://api.github.com/users/jbogard/gists{/gist_id}","starred_url":"https://api.github.com/users/jbogard/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jbogard/subscriptions","organizations_url":"https://api.github.com/users/jbogard/orgs","repos_url":"https://api.github.com/users/jbogard/repos","events_url":"https://api.github.com/users/jbogard/events{/privacy}","received_events_url":"https://api.github.com/users/jbogard/received_events","type":"User","site_admin":false},"created_at":"2016-07-06T17:09:19Z","updated_at":"2016-07-06T17:09:19Z","body":"Another option is to open a GH issue in the EF Core repo. They might already have something for this issue."}}
{"actor":{"display_login":"jbogard"}}