Troubleshooting and Debugging Visual Studio Database Projects (Especially for Post Deploy Scripts)

If you see error messages in your “Error List” window it may be because you are in a non compiled sql file. Just close all open windows and do a rebuild to see if any real issues exist on your system.

Make sure that you always rebuild before deploying or your prior build may be deployed. To be really careful, you can check the publish.sql and .dacpac files (located under your bin (Debug or Release)), and then check the timestamps on the files to make sure nothing is going on weird with your visual studio not actually building.

Error Messages on Database Projects can be confusing at best sometimes. These tips are especially useful if you are populating your tables via update scripts. Here are a few different ways to attempt to find the real error:

  1. Use the unique identifier or other unique identifier in the error message. If there isn’t one it may be hard to find the actual error.
  2. Wrap Print Messages Around all of your Post-Deploy scripts at the start and end of the script. That way you can see exactly where the publish failed.
  3. Double check spellings of any Post-Deploy or other related scripts that you try to populate.
  4. Undo all of your changes back to a known good deploy and then slowly add in the new scripts.
  5. If your issue only happens on Update, look into using a DB Up or migration script approach (I may do another quick article on this later.

Leave a Reply

Your email address will not be published. Required fields are marked *