0

I'm very new to App deployment. This is my first one actually. I developed an app which uses a SQL Server database to store its data. I created the SQL Server database with a script. However, neither the script nor the DB itself are part of the "package" of the app. I simply installed SQL Server Management Studio with the default settings, created a new file starting with

USE [Master]
GO
CREATE DATABASE [Database]

and filled up all the details. The app works in my machine of course, but when I Published the app and got the .Exe, it doesn't work in any other computer, of course because it's not creating a Database to go with it, and the connection string that it uses for the queries is the one that I gave it from my SQL Server instance.

So, I want to know how to actually include the database (or a way to create it) in the "installation package", and also for the program to dynamically get the necessary connection String to operate on any computer where its installed. Right now, I AM fetching the connection string from App.Config with the ConfigurationManager, but of course, the Connection String in App.config is the one that got added when I added MY instance to the project.

Any sort of guidance would be appreciated. I searched related questions but the only ones relevant had some deprecated methods. It's still not very clear to me how it would get the connection string dynamically if its not going to be the same instance.

On a semi-related matter...I noticed that my app was being executed with just double clicking on "setup.exe". Setup seems to imply that it will only install it and add an executable...it's kind of misleading to execute the app itself from the setup, isn't there another way to change that?

  • Take a look at DbUp https://dbup.github.io/ . You'll need to somehow figure out how to make the exe run upon deployment. This is what many people use with Octopus deploy to update changes to their databases when they deploy new versions. – onefootswill Aug 13 '20 at 01:26
  • Take a look at this: https://stackoverflow.com/questions/32956142/how-to-deploy-application-with-sql-server-database-on-clients – Nader Khazai Aug 13 '20 at 03:07
  • @Nader 's solution looks good, but I'm not sure if the current version of VS has Setup and Deployment Projects. You may need to find an extension to bring that feature back. – onefootswill Aug 13 '20 at 03:41
  • That solution seems to be outdated in general. It doesn't seem like publishing works like that anymore. –  Aug 13 '20 at 05:25

0 Answers0