As for the issue, it's almost certainly not a problem with your data being deleted but rather your database. The proper way to work with local data files is to add them to your project. By default, that data file will be copied to your output folder every time you build and it is that copy that your app connects to when it runs. In this way, you will always have a fresh database in your Release folder when it comes time to deploy your app. It also means that any modifications you make to the copy while debugging will be lost the next time you build, because the clean source database is copied over the one you made changes to.
To "fix" this issue, select the data file in the Solution Explorer, open the Properties window and change the Copy to Output Directory
property from Copy Always
to Copy if Newer
. That way, the source database will only be copied over the working database when you make changes to it, i.e. change the schema or modify the default data, in which case you would need a new copy anyway. Any changes you make while testing will be retained between sessions, even if you build you project again. If you ever want to refresh the database, simply change the property temporarily or delete the working database. A new copy will be created the next time you build again.