{"action":"created","issue":{"url":"https://api.github.com/repos/schambers/fluentmigrator/issues/660","labels_url":"https://api.github.com/repos/schambers/fluentmigrator/issues/660/labels{/name}","comments_url":"https://api.github.com/repos/schambers/fluentmigrator/issues/660/comments","events_url":"https://api.github.com/repos/schambers/fluentmigrator/issues/660/events","html_url":"https://github.com/schambers/fluentmigrator/issues/660","id":110697468,"number":660,"title":"Error when dropping column in SQL Server 2014","user":{"login":"cdroulers","id":708798,"avatar_url":"https://avatars.githubusercontent.com/u/708798?v=3","gravatar_id":"","url":"https://api.github.com/users/cdroulers","html_url":"https://github.com/cdroulers","followers_url":"https://api.github.com/users/cdroulers/followers","following_url":"https://api.github.com/users/cdroulers/following{/other_user}","gists_url":"https://api.github.com/users/cdroulers/gists{/gist_id}","starred_url":"https://api.github.com/users/cdroulers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdroulers/subscriptions","organizations_url":"https://api.github.com/users/cdroulers/orgs","repos_url":"https://api.github.com/users/cdroulers/repos","events_url":"https://api.github.com/users/cdroulers/events{/privacy}","received_events_url":"https://api.github.com/users/cdroulers/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-10-09T16:53:39Z","updated_at":"2015-10-09T16:55:14Z","closed_at":null,"body":"I have an error when dropping a column that has a foreign key in SQL Server 2014. It seems to be looking for the foreign key to drop it in `sys.default_constraints` but the key is in `sys.foreign_keys`. I'm not 100% sure this is a change in SQL Server 2014, but it's my current setup.\r\n\r\nI Can work around the issue by executing the SQL to drop the constraint since I named it myself, but I think this is a bug.\r\n\r\nI'll see about looking at the code to change it myself.\r\n\r\nThe code:\r\n\r\n```csharp\r\nDelete.Column(\"FormId\")\r\n    .FromTable(\"PaperContract\")\r\n    .InSchema(\"PaperContract\");\r\n```\r\n\r\n    Migrate.exe : !!! An error occured executing the following sql:\r\n    At line:1 char:1\r\n    + & \"C:\\dev\\vooban\\gppp\\packages\\FluentMigrator.1.5.1.0\\tools\\Migrate.e ...\r\n    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\r\n        + CategoryInfo          : NotSpecified: (!!! An error oc... following sql::String) [], RemoteException\r\n        + FullyQualifiedErrorId : NativeCommandError\r\n     \r\n    DECLARE @default sysname, @sql nvarchar(max);\r\n\r\n    -- get name of default constraint\r\n    SELECT @default = name\r\n    FROM sys.default_constraints\r\n    WHERE parent_object_id = object_id('[PaperContract].[PaperContract]\r\n    ')\r\n    AND type = 'D'\r\n    AND parent_column_id = (\r\n    SELECT column_id\r\n    FROM sys.columns\r\n    WHERE object_id = object_id('[PaperContract].[PaperContract]')\r\n    AND name = 'FormId'\r\n    );\r\n\r\n    -- create alter table command to drop constraint as string and run it\r\n    SET @sql = N'ALTER TABLE [PaperContract].[PaperContract] DROP CONSTRAINT ' + @default;\r\n    EXEC sp_executesql @sql;\r\n\r\n    -- now we can finally drop column\r\n    ALTER TABLE [PaperContract].[PaperContract] DROP COLUMN [FormId];\r\n\r\n    The error was The object 'FK_PaperContract_FormId' is dependent on column 'FormId'.\r\n    ALTER TABLE DROP COLUMN FormId failed because one or more objects access this column.\r\n\r\n    !!! The object 'FK_PaperContract_FormId' is dependent on column 'FormId'.\r\n    ALTER TABLE DROP COLUMN FormId failed because one or more objects access this column."},"comment":{"url":"https://api.github.com/repos/schambers/fluentmigrator/issues/comments/146929840","html_url":"https://github.com/schambers/fluentmigrator/issues/660#issuecomment-146929840","issue_url":"https://api.github.com/repos/schambers/fluentmigrator/issues/660","id":146929840,"user":{"login":"cdroulers","id":708798,"avatar_url":"https://avatars.githubusercontent.com/u/708798?v=3","gravatar_id":"","url":"https://api.github.com/users/cdroulers","html_url":"https://github.com/cdroulers","followers_url":"https://api.github.com/users/cdroulers/followers","following_url":"https://api.github.com/users/cdroulers/following{/other_user}","gists_url":"https://api.github.com/users/cdroulers/gists{/gist_id}","starred_url":"https://api.github.com/users/cdroulers/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cdroulers/subscriptions","organizations_url":"https://api.github.com/users/cdroulers/orgs","repos_url":"https://api.github.com/users/cdroulers/repos","events_url":"https://api.github.com/users/cdroulers/events{/privacy}","received_events_url":"https://api.github.com/users/cdroulers/received_events","type":"User","site_admin":false},"created_at":"2015-10-09T16:55:14Z","updated_at":"2015-10-09T16:55:14Z","body":"I just figured out that I'm supposed to drop the foreign key with `Delete.ForeignKey` first..."}}