Auto-update of publish in Visual Studio by zeroing the database

2

In a short time I had to create an installer for desktop application in C #, and as in Visual Studio 2013 there was Publish that already created the Setup and Auto-Update I ended up using it for the convenience, but now I have a problem, every time which publishes a new version of the application and it is downloaded, it creates a new empty database and somehow "arrows" that database to the application. If I have to restore the application to the previous version, the old database is intact with all the data.

I imagine it is easy to solve this problem, and it should be just some parameter that I did not take into account when setting up, the problem that I'm not quite sure what to look for. And the google search returns me result that is not really the answer to my problem.

    
asked by anonymous 18.11.2015 / 02:18

1 answer

2

For your connection string , you use LocalDB:

Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DataBase\Database1.mdf;I‌​ntegrated Security=True

There are two possibilities:

  • Or the Database1.mdf file is overwritten in the installation;
  • Or the publication creates a new .mdf file.

In the first case, check the Database1.mdf file by using SQL Server Management Studio . The server name is (LocalDb)\MSSQLLocalDB .

Already for the second, it is the App.config that is possibly pointing to another file. So I find it interesting to install an extension that transforms App.config and set < in> connection string manually.

    
18.11.2015 / 18:34