What happens when you make changes outside the scope of your project? What if you edit a file inside Notepad or sync your source code from your SCC system, either from the command line or from the VS IDE? Most users assume that the project automatically get updated as soon as the file is save on the local hard disk.
Lets look at a very simple example, where we make an external change to the project using Notepad.
- Create a new database project
- Add a table (by default Table1)
- Open a Command Prompt
- Open the dbo.Table1.table.sql script in Notepad
- Change the table definition, for example add column_3
- Save the script
- Now watch the Schema View tool window!
There are a couple of things to observe:
- The new column, “column_3” does not automatically show up in Schema View
- Instead a warning message/strip is displayed in the Schema View, stating “External file change, resynchronization required…“
If you click the “Synchronize” button and the message will disappear and when you expand the table node the added column is now present.
Check out a this previous blog post on the difference between Synchronize and Refresh, http://blogs.msdn.com/gertd/archive/2007/02/18/to-synchronize-or-to-refresh.aspx.
What does this mean?
It means that when you make external changes to the project, these are not automatically reflected in the underlying model. You need to synchronize or (re)build the project to sync the state of the project.
The most important time when you are exposed to this behavior is when you sync from source code control, since we do not get an event from the source code control system when the last file was synchronized, you need to synchronize or (re)build the project after you synched.
Visual Studio 2008
Because this behavior is not really discoverable we changed this in Visual Studio 2008. We added an option to automatically synchronize external file changes on idle. This option is exposed in Tools->Options->Database Tools->Design-time Validation Database: “Automatically synchronize files with the design-time validation database”. This option is turned on by default.
This new options changes the behavior in the following way. If you invalidate model by making an external change, the Schema View will still show the message strip that the underlying model is out-date. However after a while, based on the amount of changes that need to get propagated and if the system gets in to an idle state, the external changes will get picked up and the underlying model automatically will get updated. When the update has finished the message disappears.
Visual Studio 2005
So what about Visual Studio 2005 based implementations? Based on the user confusion caused by this behavior we are back porting this change to Visual Studio 2005 and we will make it available via a cumulative QFE which can be applied to v1.0 or v1.0+Service Release 1. Once the QFE is available I will post the KB article. Until then make sure when you are making external changes you underlying system is up-to-date.