如何在保持项目文件.mdf不变的情况下仅将更改保存在bin文件夹中 [英] How to save changes only the database in bin folder while keeping the project file .mdf intact

查看:45
本文介绍了如何在保持项目文件.mdf不变的情况下仅将更改保存在bin文件夹中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在一个集成测试项目中,在该项目的解决方案文件中有一个本地数据库,该数据库在每次编译时都被复制到"bin/debug"中,然后再使用.

现在,我需要仅在调试模式下对数据库进行更改,以便我们不对原始数据库进行任何更改,并且不会将大型数据库文件推送到源代码管理中.

我知道Visual Studio中有一个选项,它导致仅将数据更改为bin文件夹中的数据库,而原始数据库保持不变,我想要的是完全一样的东西.

此外,我只需要在第一次构建时(当bin中没有.mdf时)将原始数据库复制到bin文件夹中.

Visual Studio中数据库文件的属性如下:

内容>始终复制

我的连接字符串是这样:

<添加名称="MaxDatabase"connectionString ="Data Source =(LocalDb)\ ProjectsV13;初始目录=目录= MaxLocalEmbeded;集成安全性= SSPI"providerName ="System.Data.SqlClient"/>

我在这里需要类似OP的问题:

当然,您可以简单地从同一窗口中调用批处理文件,并传递一些

I need something like the OP's problem here: https://stackoverflow.com/a/17147460/5360889

Any help with this will be highly appreciated. Thanks!

解决方案

If I understand your problem correctly then you could change the MDF property to Copy Never and add a pre-build script to your project file to copy the file to the bin\debug folder only if it doesn't exist –

Of course you could simply call a batch file from the same window, passing some of the predefined macros and write very complex pre or post behaviors for each of your project files in your solution.
However, when using a batch file, as specified in the note in the previous link, don't forget to prepend the name of the batch file with the keyword call

这篇关于如何在保持项目文件.mdf不变的情况下仅将更改保存在bin文件夹中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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