Changes to Access database do not persist when running app in Visual Studio

It is a very common situation. You have your database file (the MDB or ACCDB file) listed between your project items. If you click on this file and look at the properties window you will see a property called Copy to the output directory. If this property is set to Copy Always then every time you start a debug session the database file listed in your project items is copied by VS in the output directory (usually BIN\DEBUG). Of course this copy doesn’t contain the records inserted in your last debug session and you think that your previous insert has failed.

Setting this property to Copy If Newer, the mentioned behavior will happen only if you change the database schema manually.

Setting this property to Copy Never, will let you manually copy the database file.

Leave a Comment