Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can I commit changes to actual database while debugging C# in Visual Studio?

I am creating a C# application using Visual Studio that uses an SQLExpress database. When I hit f5 to debug the application and make changes to the database I believe what is happening is there is a copy of the database in the bin/debug folder that changes are being made to.

However, when I stop the debugging and then hit f5 the next time a new copy of the database is being put in the bin/debug folder so that all the changes made the last time are gone.

My question is:

Is there a way that when I am debugging the application I can have it make changes to the actual database and those changes are actually saved or will it only make changes to the copy in the bin/debug folder (if that is what is actually happening)?

I've seen similar questions, but I couldn't find an answer that said if it's possible to make those changes persistent in the actual .mdf file.

The reason I ask is because as I build this application I am continuously adding pieces and testing to make sure they all work together. When I put in test data I am using actual data that I would like to stay in the database. This would just help me not have to reenter the data later.

Thanks in advance for any help or information that could help me better understand the process.

like image 770
nathant23 Avatar asked Dec 13 '22 16:12

nathant23


1 Answers

Select the databases in Solution Explorer and change the "Copy to Output Directory" to "Copy if newer". Later, when you finally get the final version, copy paste the databases in debug folder to your source folders

like image 81
Martheen Avatar answered Dec 15 '22 04:12

Martheen