Replace .SDF database file through .msi upgrade proceed
http://msdn.microsoft.com/en-us/library/windows/desktop/aa371221(v=vs.85).aspx
Since there's no File Version attribute for the SDF database file for the Existing File replacement policy, but sometimes we really need to replace the SDF file(change the init data, or others things makes you need to replace the database file).
Then we just can edit the .MSI file File table to add the File Version number for the .SDF file, then it can use the Existing File replacement policy:
Then we just need to update the version number once we need to replace the .sdf database file for our product.
Then we can configure the Setup project Post-build Event according to this command to update the msi file:
Cscript WiRunSQL.vbs Setup2.msi "UPDATE `File` SET `File`.`Version`='1.0.0.0' WHERE `File`.`FileName` = 'DATABA~1.SDF|Database1.sdf'"
[C:\Program Files\Microsoft SDKs\Windows\v7.1\Samples\sysmgmt\msi\scripts\WiRunSQL.vbs]
I have not found any MSDN document mentioned this way to help our work, this is just based on my experiences and test cases, so please consider carefully before use this way in your product deployment.
ref my Google Blog: http://mikedoszhang.blogspot.com/2012/02/replace-sdf-database-file-through-msi.html