{"action":"created","issue":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5415","repository_url":"https://api.github.com/repos/aspnet/EntityFramework","labels_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5415/labels{/name}","comments_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5415/comments","events_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5415/events","html_url":"https://github.com/aspnet/EntityFramework/issues/5415","id":155676885,"number":5415,"title":"Migrations: Opt out from IS NOT NULL in index creation","user":{"login":"rmja","id":2112306,"avatar_url":"https://avatars.githubusercontent.com/u/2112306?v=3","gravatar_id":"","url":"https://api.github.com/users/rmja","html_url":"https://github.com/rmja","followers_url":"https://api.github.com/users/rmja/followers","following_url":"https://api.github.com/users/rmja/following{/other_user}","gists_url":"https://api.github.com/users/rmja/gists{/gist_id}","starred_url":"https://api.github.com/users/rmja/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rmja/subscriptions","organizations_url":"https://api.github.com/users/rmja/orgs","repos_url":"https://api.github.com/users/rmja/repos","events_url":"https://api.github.com/users/rmja/events{/privacy}","received_events_url":"https://api.github.com/users/rmja/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":7,"created_at":"2016-05-19T08:07:49Z","updated_at":"2016-05-31T17:21:47Z","closed_at":"2016-05-31T17:21:47Z","body":"[When creating an index in migrations](https://github.com/aspnet/EntityFramework/blob/ce07379ec2d5e5e6d3e6077267bcd7c1dde58f92/src/Microsoft.EntityFrameworkCore.SqlServer/Migrations/SqlServerMigrationsSqlGenerator.cs#L198) it would be nice if it was possible to specify on a per column basis whether the column should be generated as NOT NULL. Right now all columns are NOT NULL if the index is not clustered.\r\n\r\nMore generally, it would be nice if provider specific details were implemented in seperate overrideable methods, so that one could implement this with a custom migrations SQL generator. For example:\r\n\r\n```\r\nprotected override void Generate(CreateIndexOperation operation, IModel model, MigrationCommandListBuilder builder)\r\n        {\r\n            Check.NotNull(operation, nameof(operation));\r\n            Check.NotNull(builder, nameof(builder));\r\n\r\n            base.Generate(operation, model, builder, terminate: false);\r\n            AppendIndexWhere(operation, model, builder);\r\n\r\n            EndStatement(builder);\r\n        }\r\n\r\nprotected virtual void AppendIndexWhere(CreateIndexOperation operation, IModel model, MigrationCommandListBuilder builder)\r\n{\r\n            var clustered = operation[SqlServerFullAnnotationNames.Instance.Clustered] as bool?;\r\n            if (operation.IsUnique\r\n                && (clustered != true))\r\n            {\r\n                builder.Append(\" WHERE \");\r\n                for (var i = 0; i < operation.Columns.Length; i++)\r\n                {\r\n                    if (i != 0)\r\n                    {\r\n                        builder.Append(\" AND \");\r\n                    }\r\n\r\n                    builder\r\n                        .Append(SqlGenerationHelper.DelimitIdentifier(operation.Columns[i]))\r\n                        .Append(\" IS NOT NULL\");\r\n                }\r\n            }\r\n}\r\n```\r\n\r\nIn this way I can call `base.Generate()` from a derived custom SQL generator and override the provider behaviour where needed by overriding each step. This is because I cannot call `base.base.Generate()` from my custom SQL generator, so it is currently an all or nothing situation."},"comment":{"url":"https://api.github.com/repos/aspnet/EntityFramework/issues/comments/222758202","html_url":"https://github.com/aspnet/EntityFramework/issues/5415#issuecomment-222758202","issue_url":"https://api.github.com/repos/aspnet/EntityFramework/issues/5415","id":222758202,"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":"2016-05-31T17:21:47Z","updated_at":"2016-05-31T17:21:47Z","body":"We'll avoid creating the redundant checks, tracking this with https://github.com/aspnet/EntityFramework/issues/5532."}}
{"actor":{"display_login":"rowanmiller"}}