{"action":"opened","issue":{"url":"https://api.github.com/repos/aspnet/Identity/issues/1015","repository_url":"https://api.github.com/repos/aspnet/Identity","labels_url":"https://api.github.com/repos/aspnet/Identity/issues/1015/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/Identity/issues/1015/comments","events_url":"https://api.github.com/repos/aspnet/Identity/issues/1015/events","html_url":"https://github.com/aspnet/Identity/issues/1015","id":187136171,"number":1015,"title":"IdentityUserClaim and IdentityRoleClaim Id primary key assumes identity column","user":{"login":"brockallen","id":649492,"avatar_url":"https://avatars.githubusercontent.com/u/649492?v=3","gravatar_id":"","url":"https://api.github.com/users/brockallen","html_url":"https://github.com/brockallen","followers_url":"https://api.github.com/users/brockallen/followers","following_url":"https://api.github.com/users/brockallen/following{/other_user}","gists_url":"https://api.github.com/users/brockallen/gists{/gist_id}","starred_url":"https://api.github.com/users/brockallen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/brockallen/subscriptions","organizations_url":"https://api.github.com/users/brockallen/orgs","repos_url":"https://api.github.com/users/brockallen/repos","events_url":"https://api.github.com/users/brockallen/events{/privacy}","received_events_url":"https://api.github.com/users/brockallen/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2016-11-03T17:24:22Z","updated_at":"2016-11-03T17:24:22Z","closed_at":null,"body":"Both the `IdentityUserClaim` and `IdentityRoleClaim` have an `int Id` property for primary keys. When running with SqlServer these work fine because somehow in the creation of the SqlServer DB the schema knows that these are to be identity column types. But when running with RDS (https://en.wikipedia.org/wiki/Amazon_Relational_Database_Service) the DB does not because there is no explicit configuration for this in `OnModelCreating`. This is what is looks like:\r\n\r\n```\r\nbuilder.Entity<TUserClaim>(b => \r\n            {\r\n                b.HasKey(uc => uc.Id);\r\n                b.ToTable(\"AspNetUserClaims\");\r\n            });\r\n```\r\n\r\nAt runtime when trying to add a claim:\r\n\r\n```\r\nawait mgr.AddClaimAsync(user, new Claim(\"name\", \"Jon Doe\"));\r\n```\r\n\r\nI'm getting an exception at runtime saying that Id is not being set (presumably by the DB at insert time):\r\n\r\n> {Npgsql.PostgresException: 23502: null value in column \"Id\" violates not-null constraint\r\n   at Npgsql.NpgsqlConnector.<DoReadMessageAsync>d__6.MoveNext()\r\n\r\nI'm wondering if `OnModelCreating` should have an additional:\r\n\r\n```\r\nb.Property(x => x.Id).ValueGeneratedOnAdd()\r\n```\r\n\r\nI assume this tells the DB schema to make the column an identity column?"}}
{"actor":{"display_login":"brockallen"}}