Attaching database to my project [closed]

試著忘記壹切 提交于 2019-12-04 19:30:44

Your database file has 2 copies. One is in your project and the other is in bin\debug. In design time you edit the one in your project. Each time your project changes and you build it, the project database file is overwriting the file in bin\debug, and this file you're updating in run-time.

In order to solve that you have three options:

  1. Use only the file in bin\debug. Set the project database file copy options to "Never" (in the properties window), show all files of the project and add the bin\debug database file to the server explorer. Caution: If you accidently delete the bin\debug folder all your changes are gone. Manually copy the database file from bin\debug to the project folder when you change it.

  2. Put the file in your sql server folder and not in your project. When deploying, change the connection string and copy the database from server.

  3. Replace "|DataDirectory|" macro with the absolute path to the project database file. When deploying, just change it back to "|DataDirectory|"

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!