Right now I am so excited, and a little embarrassed. After using Visual Studio (VS) for database projects for the last 7 years, I am just now finding out about this feature?! What feature is that, you ask? Let me tell you…
When using VS for database projects I typically use my environment specific Publish xml file to deploy changes to my local database when experimenting with code changes. However, every once in a while I will have to use the New Schema Compare tool from the Tools | SQL Server menu when I have a “one-off” database that I need to synch to my database project.
Quite frequently because these are one-off databases there will be a ton of junk items that are in the database, but not in my database project or lots of objects in my project that aren’t in my database. Either way I want to ignore those changes. In the past, I’ve always manually unchecked each item, tedious when you have more than two items to uncheck.
I always thought there should be a better way than having to manually uncheck each object, but never thought more about or how to do it.
Well, today I figured it out. All you have to do is right click on the section and ta-da, you can Include or Exclude all objects depending on the existing state of the objects. So in the image below, I right click on Delete, select Exclude
and I’m left with the following:
In just one click instead of 14 (if I wanted to exclude all the table drops).
Like I said, I have no idea why it took me so long to figure this out, but surely I can’t be the only person who didn’t know this, so now you do too.