{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6035","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6035/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6035/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6035/events","html_url":"https://github.com/aspnet/EntityFramework/issues/6035","id":164659561,"number":6035,"title":"AddColumn migrations created with bad default","user":{"login":"roji","id":1862641,"avatar_url":"https://avatars.githubusercontent.com/u/1862641?v=3","gravatar_id":"","url":"https://api.github.com/users/roji","html_url":"https://github.com/roji","followers_url":"https://api.github.com/users/roji/followers","following_url":"https://api.github.com/users/roji/following{/other_user}","gists_url":"https://api.github.com/users/roji/gists{/gist_id}","starred_url":"https://api.github.com/users/roji/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/roji/subscriptions","organizations_url":"https://api.github.com/users/roji/orgs","repos_url":"https://api.github.com/users/roji/repos","events_url":"https://api.github.com/users/roji/events{/privacy}","received_events_url":"https://api.github.com/users/roji/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/closed-fixed","name":"closed-fixed","color":"777777"},{"url":"https://api.github.com/repos/aspnet/EntityFramework/labels/type-bug","name":"type-bug","color":"f7c6c7"}],"state":"closed","locked":false,"assignee":{"login":"bricelam","id":1226749,"avatar_url":"https://avatars.githubusercontent.com/u/1226749?v=3","gravatar_id":"","url":"https://api.github.com/users/bricelam","html_url":"https://github.com/bricelam","followers_url":"https://api.github.com/users/bricelam/followers","following_url":"https://api.github.com/users/bricelam/following{/other_user}","gists_url":"https://api.github.com/users/bricelam/gists{/gist_id}","starred_url":"https://api.github.com/users/bricelam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bricelam/subscriptions","organizations_url":"https://api.github.com/users/bricelam/orgs","repos_url":"https://api.github.com/users/bricelam/repos","events_url":"https://api.github.com/users/bricelam/events{/privacy}","received_events_url":"https://api.github.com/users/bricelam/received_events","type":"User","site_admin":false},"assignees":[{"login":"bricelam","id":1226749,"avatar_url":"https://avatars.githubusercontent.com/u/1226749?v=3","gravatar_id":"","url":"https://api.github.com/users/bricelam","html_url":"https://github.com/bricelam","followers_url":"https://api.github.com/users/bricelam/followers","following_url":"https://api.github.com/users/bricelam/following{/other_user}","gists_url":"https://api.github.com/users/bricelam/gists{/gist_id}","starred_url":"https://api.github.com/users/bricelam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bricelam/subscriptions","organizations_url":"https://api.github.com/users/bricelam/orgs","repos_url":"https://api.github.com/users/bricelam/repos","events_url":"https://api.github.com/users/bricelam/events{/privacy}","received_events_url":"https://api.github.com/users/bricelam/received_events","type":"User","site_admin":false}],"milestone":{"url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/19","html_url":"https://github.com/aspnet/EntityFramework/milestones/1.1.0","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/milestones/19/labels","id":1748298,"number":19,"title":"1.1.0","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":115,"closed_issues":184,"state":"open","created_at":"2016-05-04T18:23:47Z","updated_at":"2016-09-09T17:53:36Z","due_on":null,"closed_at":null},"comments":26,"created_at":"2016-07-09T09:35:35Z","updated_at":"2016-09-12T16:28:54Z","closed_at":"2016-08-10T22:34:39Z","body":"Hope I'm not reporting a dup here.\r\n\r\nTesting with SqlServer, I've added this property to my model:\r\n\r\n```c#\r\nbuilder.Entity<Blog>().Property(b => b.SomeProp).ValueGeneratedOnAdd();\r\n```\r\n\r\nGenerating a migration creates the following code:\r\n\r\n```c#\r\nmigrationBuilder.AddColumn<int>(\r\n\tname: \"SomeProp\",\r\n\ttable: \"Blogs\",\r\n\tnullable: false,\r\n\tdefaultValue: 0)\r\n\t.Annotation(\"SqlServer:ValueGenerationStrategy\", SqlServerValueGenerationStrategy.IdentityColumn);\r\n```\r\n\r\nNote the `defaultValue: 0`, which I didn't specify in the model in any way. Note also that if the column is defined when creating the table, the correct CreateTable migration is generated:\r\n\r\n```c#\r\nSomeProp = table.Column<int>(nullable: false)\r\n    .Annotation(\"SqlServer:ValueGenerationStrategy\", SqlServerValueGenerationStrategy.IdentityColumn),\r\n```\r\n\r\nThis causes an issue with Npgsql (https://github.com/npgsql/Npgsql.EntityFrameworkCore.PostgreSQL/issues/68) since the default value is examined in the migration decision process."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/246405009","html_url":"https://github.com/aspnet/EntityFramework/issues/6035#issuecomment-246405009","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/6035","id":246405009,"user":{"login":"ajcvickers","id":1430078,"avatar_url":"https://avatars.githubusercontent.com/u/1430078?v=3","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},"created_at":"2016-09-12T16:28:54Z","updated_at":"2016-09-12T16:28:54Z","body":"@roji I think @bricelam is probably better able to answer that."}}
{"actor":{"display_login":"ajcvickers"}}