开发者

Install WPF application and create database

开发者 https://www.devze.com 2023-01-19 19:22 出处:网络
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 s

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消