在Visual Studio中调试C#时,是否可以将更改提交到实际数据库? [英] Can I commit changes to actual database while debugging C# in Visual Studio?

查看:182
本文介绍了在Visual Studio中调试C#时,是否可以将更改提交到实际数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用Visual Studio使用SQLExpress数据库创建一个C#应用程序。当我按f5调试应用程序并对数据库进行更改时,我相信正在发生的是在bin / debug文件夹中有一个正在进行更改的数据库副本。

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.

然而,当我停止调试,然后命中f5下一次数据库的新副本被放在bin / debug文件夹,使上次所做的所有更改都消失。

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.

我的问题是:

有一种方法,当我调试应用程序,我可以让它更改实际数据库和那些更改实际上是保存或将只更改bin / debug文件夹中的副本(如果这是真正发生的事情)?

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)?

看到类似的问题,但我找不到一个答案,如果可能使这些更改持续在实际的.mdf文件。

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.

推荐答案

在解决方案资源管理器中选择数据库,并将复制到输出目录更改为如果更新则复制。稍后,当您终于获得最终版本时,请将调试文件夹中的数据库复制到源文件夹中

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

这篇关于在Visual Studio中调试C#时,是否可以将更改提交到实际数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆