SQLTeam.com | Weblogs | Forums

Deploying SQL Express + Database + Application from a setup.exe?


I have written a solution in VS 2015 which is architected such that a C# WinForms front-end can access the App Engine, which does the work. The C# WinForms app can be installed using ClickOnce, or I suppose I can make an installer for it using WiX Installer if I had to.

My App Engine is simply a SQL Client application designed to install SQL Server Express Edition and also install the database it uses, which is packaged into a DACPAC.

So far so good. In VS2015, I have one solution which contains the following assemblies:

  • Database Project (DAC)
  • App Engine (DLL)
  • C# Winforms Front End (EXE)
  • Possibly a Setup project using WiX Installer

Now how do I deploy the C# WinForms app to a fresh workstation that does not have anything on it? I would like to install using the ClickOnce technology, and avoid using WiX because it shouldn't be a complex install.

So I realize I can install the C# WinForms app and declare a dependency on SQL Server Express Edition. This causes the SQL Server Express Edition msi to deploy first, followed by my C# WinForms app, but there is no database yet!

So I read further, and found that I either need SqlPackage.exe or DacFx to unpack and install the database.


  1. Which project do I put the DacFx into? This should be a pretty common scenario.
  2. If the WinForm detects that there isn't a database responding to the SQL Client on the first load, should I put the DacFx database installer code into that event?
  3. If not, how do I put the DacFx or SqlPackage.exe calls into the installer?

Basically, are there any best-practices for executing SETUP.EXE and achieving an install of SQL Express + Database + Application?


so this is being deployed on how many workstations?


The WinForms app can be installed on a single workstation.

I left out the remainder of the architecture for simplicity ... I also have an ASP .net front-end which can use the App Engine as well; but the customer I'm writing this for says there is only one human user, so the website was completely overkill. I decided that I'd make a quick-win and write a WinForms app to make this app usable without needing a website.

Anyway, the App Engine is the only thing that talks to the database.

~ Shaun


gotcha. so why such a complicated deployment plan for one human user?


because I'm being paid to write it and I wanted it to be professional. I ended up writing a batch (cmd) file that ties all of the installation together.