每当我运行我的项目时,数据库都会被复制到bin文件夹,这样当我进行任何更改时,它们会在下次运行项目时丢失,它会恢复到原始数据库并再次复制新的更新数据库在bin文件夹中的文件.
任何想法如何阻止这种情况发生,或至少强制Visual Studio使用相同的数据库?
解决方法
你可以使用
Copy if newer :
The database file is copied from the project directory to the bin directory the first time the project is built. Every subsequent time you build the project,the Date Modified property of the files is compared. If the file in the project folder is newer,it is copied to the bin folder,replacing the file that is currently there. If the file in the bin folder is newer,no files are copied. This setting persists any changes made to the data during run time,meaning that every time you run your application and save changes to the data,those changes are visible the next time you run your application.
将“复制到输出目录”属性设置为“如果更新则复制”单击数据库,并在属性窗口中将“复制到输出目录”更改为“如果更新则复制”.
编辑:如果您只想要主数据库并防止复制到输出,您可以更改连接字符串以指向主数据库,并将复制到输出目录更改为不复制.
(编辑:李大同)
【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!
|