Whenever I run my project, the database is copied to the bin folder, so that when I make any changes, they are effectively lost as the next time I run the project, it reverts back to the original database and again, copies the new updated database over the file in the bin folder.
Any ideas how I can stop this from happening, or at least force Visual Studio to use the same database?
You could use Copy if newer
:
The database file is copied from the project directory to the bin directory the first time the project is built. Every subsequent time you build the project, the Date Modified property of the files is compared. If the file in the project folder is newer, it is copied to the bin folder, replacing the file that is currently there. If the file in the bin folder is newer, no files are copied. This setting persists any changes made to the data during run time, meaning that every time you run your application and save changes to the data, those changes are visible the next time you run your application.
To set Copy to Output Directory
property to Copy if newer
Click on the database and change Copy to Output Directory
to Copy if newer
in the properties window.
EDIT: If you just want the main database and prevent from copying to output you can change your connection string to point to your main database and also change the Copy to Output Directory
to Do not copy
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With