I have a WPF application that runs开发者_开发百科 on a small database. Using clickonce or any one-click solution the users want to install the application locally and also set up the database at the same time. All users run SQL Server locally, so that is doable.
Can someone tell me how I can do that using a single mouse click?
Thanks PN
The simplest approach would be to include a copy of the database with all tables, stored procedures etc. present in the installation package.
If you are using ClickOnce, make sure that the database is included as a "Data File (Auto)" in the Publish Status column and "(Required)" in the Download Group column.
Then as long as you reference the database via a relative path it should "just work" once it's been installed.
Be aware how ClickOnce manage to upgrade the database. It is suggested to put DataBase outside the default clickonce deployment folder. I suggest the User\AppData folder witch is covered by roaming as well. Otherwise you have to manage database upgrades while upgrading the app. This is done by moving data from _old datafile to _new one.
精彩评论