{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3148","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3148/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3148/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3148/events","html_url":"https://github.com/aspnet/EntityFramework/issues/3148","id":106742467,"number":3148,"title":"Entity type cannot be tracked exception from derived AspNet.Idenity user class","user":{"login":"leak","id":530056,"avatar_url":"https://avatars.githubusercontent.com/u/530056?v=3","gravatar_id":"","url":"https://api.github.com/users/leak","html_url":"https://github.com/leak","followers_url":"https://api.github.com/users/leak/followers","following_url":"https://api.github.com/users/leak/following{/other_user}","gists_url":"https://api.github.com/users/leak/gists{/gist_id}","starred_url":"https://api.github.com/users/leak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leak/subscriptions","organizations_url":"https://api.github.com/users/leak/orgs","repos_url":"https://api.github.com/users/leak/repos","events_url":"https://api.github.com/users/leak/events{/privacy}","received_events_url":"https://api.github.com/users/leak/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":"open","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},"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":89,"closed_issues":57,"state":"open","created_at":"2015-09-17T20:13:31Z","updated_at":"2015-10-13T23:32:09Z","due_on":"2015-11-30T08:00:00Z","closed_at":null},"comments":2,"created_at":"2015-09-16T10:14:06Z","updated_at":"2015-10-14T18:11:59Z","closed_at":null,"body":"The following exception only occurs when running a custom dnx command to seed the database on an application that has been published on a server without VS2015 being installed.\r\n\r\n```\r\nSystem.InvalidOperationException: The instance of entity type 'MyApp.Database.Entities.User' cannot be tracked because it has an invalid (e.g. null or CLR default) primary key. Either set the key explicitly or consider using an IValueGenerator to generate unique key values.\r\n   at Microsoft.Data.Entity.ChangeTracking.Internal.StateManager.GetKeyValueChecked(IKey key, InternalEntityEntry entry)\r\n   at Microsoft.Data.Entity.ChangeTracking.Internal.StateManager.StartTracking(InternalEntityEntry entry)\r\n   at Microsoft.Data.Entity.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState oldState, EntityState newState, Boolean acceptChanges)\r\n   at Microsoft.Data.Entity.ChangeTracking.Internal.InternalEntityEntry.SetEntityState(EntityState entityState, Boolean acceptChanges)\r\n   at Microsoft.Data.Entity.DbContext.Attach[TEntity](TEntity entity)\r\n   at Microsoft.AspNet.Identity.EntityFramework.UserStore`4.<UpdateAsync>d__21.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.UserManager`1.<UpdateUserAsync>d__149.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at Microsoft.AspNet.Identity.UserManager`1.<AddToRoleAsync>d__92.MoveNext()\r\n```\r\n\r\nThe class in question is derived from `Microsoft.AspNet.Identity.EntityFramework.IdentityUser` the property in question is `public virtual TKey Id { get; set; }`\r\n\r\n````\r\n    public class User : IdentityUser<int>\r\n    {\r\n        private ICollection<Search> _searches;\r\n        public virtual ICollection<Search> Searches => _searches ?? (_searches = new List<Search>());\r\n\r\n        private ICollection<NotificationRule> _notificationRules;\r\n        public virtual ICollection<NotificationRule> NotificationRules => _notificationRules ?? (_notificationRules = new List<NotificationRule>());\r\n    }\r\n````\r\n\r\nThe migration created this field properly as\r\n````\r\n            migrationBuilder.CreateTable(\r\n                name: \"AspNetUsers\",\r\n                columns: table => new\r\n                {\r\n                    Id = table.Column<int>(isNullable: false)\r\n                        .Annotation(\"Sqlite:Autoincrement\", true),\r\n````\r\n\r\nRunning the dnx command within the dev environment it seems to work after expicitly specifying `modelBuilder.Entity<User>().Key(y => y.Id);`. In the published application the issue persists. All packages are beta7."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/148141287","html_url":"https://github.com/aspnet/EntityFramework/issues/3148#issuecomment-148141287","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/3148","id":148141287,"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-14T18:11:59Z","updated_at":"2015-10-14T18:11:59Z","body":"@smitpatel can you just verify that this is fixed"}}