0

I have a project with a SQL Server Compact database included.

  1. I build the solution it is built into bin/Release.
  2. I then publish the project from bin/Release to a file server directory where I install it.
  3. I then add some rows to the database in the published application file via its a Winforms then its database gets updated with these additional rows.
  4. I then go back to the solution in Visual Studio and add some buttons to the form and also add some rubbish records to its database.
  5. I then rebuild and publish this new version to the file server and run the application

What I notice is that the new buttons from 4 are now on the form but the rubbish rows I added in 4 are not - the db is preserved in the state I left it in 3.

Is there a setting, in the solution, that I can change so that rather than the application databases being preserved they get overwritten by the database in solutions bin/Release files ?

whytheq
  • 34,466
  • 65
  • 172
  • 267

1 Answers1

1

Right click on the database file in visual studio and under the "Copy to Output Directory" field select "Copy always". This will replace the database file in your bin/Release folder with the one in the project folder every time you rebuild the project.

Kendall Trego
  • 1,975
  • 13
  • 21
  • thanks...but what about when it is published? will the db in the published version get over-written – whytheq Jul 24 '12 at 19:27
  • It should overwrite it and use the files out of the release folder, isn't this happening? – Kendall Trego Jul 24 '12 at 20:41
  • testing now; I see there's another property "Build Action" - currently set to Content - what does this do? – whytheq Jul 24 '12 at 21:28
  • Content should be fine - from another stackoverflow comment here http://stackoverflow.com/questions/145752/what-are-the-various-build-action-settings-in-vs-net-project-properties-and-wh Content: Allows you to retrieve a file (in same dir as assembly) as a stream via Application.GetContentStream( uri ). For this method to work, it needs a AssemblyAssociatedContentFile custom attribute which VS graciously adds when you mark a file as "Custom" – Kendall Trego Jul 24 '12 at 21:34