{"action":"closed","issue":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13662","repository_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13662/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13662/comments","events_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/issues/13662/events","html_url":"https://github.com/aspnet/EntityFrameworkCore/issues/13662","id":371329657,"node_id":"MDU6SXNzdWUzNzEzMjk2NTc=","number":13662,"title":"NullReferenceException in IdentityMap<>.TryGetValue","user":{"login":"markgould","id":2712328,"node_id":"MDQ6VXNlcjI3MTIzMjg=","avatar_url":"https://avatars2.githubusercontent.com/u/2712328?v=4","gravatar_id":"","url":"https://api.github.com/users/markgould","html_url":"https://github.com/markgould","followers_url":"https://api.github.com/users/markgould/followers","following_url":"https://api.github.com/users/markgould/following{/other_user}","gists_url":"https://api.github.com/users/markgould/gists{/gist_id}","starred_url":"https://api.github.com/users/markgould/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/markgould/subscriptions","organizations_url":"https://api.github.com/users/markgould/orgs","repos_url":"https://api.github.com/users/markgould/repos","events_url":"https://api.github.com/users/markgould/events{/privacy}","received_events_url":"https://api.github.com/users/markgould/received_events","type":"User","site_admin":false},"labels":[{"id":403964217,"node_id":"MDU6TGFiZWw0MDM5NjQyMTc=","url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/labels/closed-fixed","name":"closed-fixed","color":"777777","default":false},{"id":936619505,"node_id":"MDU6TGFiZWw5MzY2MTk1MDU=","url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/labels/customer-reported","name":"customer-reported","color":"a4a5f9","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/milestones/47","html_url":"https://github.com/aspnet/EntityFrameworkCore/milestone/47","labels_url":"https://api.github.com/repos/aspnet/EntityFrameworkCore/milestones/47/labels","id":3740595,"node_id":"MDk6TWlsZXN0b25lMzc0MDU5NQ==","number":47,"title":"2.2.0","description":"","creator":{"login":"ajcvickers","id":1430078,"node_id":"MDQ6VXNlcjE0MzAwNzg=","avatar_url":"https://avatars1.githubusercontent.com/u/1430078?v=4","gravatar_id":"","url":"https://api.github.com/users/ajcvickers","html_url":"https://github.com/ajcvickers","followers_url":"https://api.github.com/users/ajcvickers/followers","following_url":"https://api.github.com/users/ajcvickers/following{/other_user}","gists_url":"https://api.github.com/users/ajcvickers/gists{/gist_id}","starred_url":"https://api.github.com/users/ajcvickers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajcvickers/subscriptions","organizations_url":"https://api.github.com/users/ajcvickers/orgs","repos_url":"https://api.github.com/users/ajcvickers/repos","events_url":"https://api.github.com/users/ajcvickers/events{/privacy}","received_events_url":"https://api.github.com/users/ajcvickers/received_events","type":"User","site_admin":false},"open_issues":9,"closed_issues":34,"state":"open","created_at":"2018-10-15T17:48:39Z","updated_at":"2018-10-24T23:03:41Z","due_on":null,"closed_at":null},"comments":4,"created_at":"2018-10-18T01:49:06Z","updated_at":"2018-10-24T23:03:41Z","closed_at":"2018-10-24T23:03:41Z","author_association":"NONE","body":"Mapping from a table to a view does not appear to be working correctly. A table with a one to many relationship with a view works when querying the view and including the parent table. When querying the parent table and including the view, a null reference exception happens. It appears to be related to the Foreign Key.\r\n\r\n```\r\n{System.NullReferenceException: Object reference not set to an instance of an object.\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.IdentityMap`1.TryGetEntry(IForeignKey foreignKey, InternalEntityEntry dependentEntry)\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.InitialFixup(InternalEntityEntry entry, ISet`1 handledForeignKeys, Boolean fromQuery)\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.NavigationFixer.TrackedFromQuery(InternalEntityEntry entry, ISet`1 handledForeignKeys)\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.InternalEntityEntryNotifier.TrackedFromQuery(InternalEntityEntry entry, ISet`1 handledForeignKeys)\r\n   at Microsoft.EntityFrameworkCore.ChangeTracking.Internal.StateManager.StartTrackingFromQuery(IEntityType baseEntityType, Object entity, ValueBuffer& valueBuffer, ISet`1 handledForeignKeys)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryBuffer.StartTracking(Object entity, IEntityType entityType)\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.QueryBuffer.IncludeCollection[TEntity,TRelated,TElement](Int32 includeId, INavigation navigation, INavigation inverseNavigation, IEntityType targetEntityType, IClrCollectionAccessor clrCollectionAccessor, IClrPropertySetter inverseClrPropertySetter, Boolean tracking, TEntity entity, Func`1 relatedEntitiesFactory, Func`3 joinPredicate)\r\n   at lambda_method(Closure , QueryContext , Account , Object[] )\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.IncludeCompiler._Include[TEntity](QueryContext queryContext, TEntity entity, Object[] included, Action`3 fixup)\r\n   at lambda_method(Closure , Account )\r\n   at System.Linq.Enumerable.SelectEnumerableIterator`2.MoveNext()\r\n   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()\r\n   at System.Collections.Generic.List`1.AddEnumerable(IEnumerable`1 enumerable)\r\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n   at EFCoreRepro.Program.Main(String[] args) in C:\\Users\\mgould\\source\\repos\\EFCoreRepro\\Program.cs:line 49}\tSystem.NullReferenceException\r\n\r\n```\r\n\r\n\r\n### Steps to reproduce\r\nCode:\r\n[repro.txt](https://github.com/aspnet/EntityFrameworkCore/files/2489885/repro.txt)\r\n\r\nDatabase script:\r\n[script.txt](https://github.com/aspnet/EntityFrameworkCore/files/2489889/script.txt)\r\n\r\nIf you change the View to use a DbSet/Entity definition instead of the DbQuery method, it runs successfully. Let me know if I can provide any further information. \r\n\r\n\r\n\r\n### Further technical details\r\nEF Core version: 2.1.4\r\nDatabase Provider:  Microsoft.EntityFrameworkCore.SqlServer\r\nOperating system: Windows 10 x64\r\nIDE: Visual Studio 2017 15.8.7\r\n"}}
{"actor":{"display_login":"AndriySvyryd"}}