Thanks for your post.
In most cases, a duplicate definition occurs within the files in your repository rather than the database itself. There's a few causes, the most common either being a user has manually altered the files in some way or it's a bug.
To find the offending file, it's usually possible to check out a copy of your repo to a temporary folder on your machine using the tool supplied with your source control system (i.e. Tortoise if you use SVN etc).
Once checked out, you can run a command to locate all instances of the object in the error message ([dbo].[Documents]) - running this command in the root of the checkout folder:
- Code: Select all
findstr /S /C:"[dbo].[Documents]" *.*
Hopefully that will yield more than one file which contains the creation SQL for the FK in question (or the definition will be duplicated in one file, although we tend to see that more with triggers) - once you find the issue, you'll need to correct it in the repository copy of the file, and finally unlink and relink the database from source control to refresh our working copies. Hopefully that should sort it out.