Auto-update of Publish in Visual Studio zeroing the database

Asked

Viewed 94 times

2

Soon I had to create an installer for desktop application in c#, and as in visual studio 2013 there was Publish that already created Setup and Auto-Update I ended up using it for convenience, but now I have a problem, every time I publish a new version of the application and it is downloaded, it creates a new empty database and somehow "arrow" that database for the application. If I have the application restored to the previous version, the old database is there intact with all the data.

I imagine that it is easy to solve this problem, and it must be just some parameter that I did not take into account when setting up, the problem that I am not sure what to look for. And google searches return me results that are not really the answer to my problem.

  • Your application uses Entity Framework?

  • No. All in the same hand.

  • How is your publication procedure? Can you describe the steps?

  • Ta well default even, Build -> Publish -> next next next Finish.

  • In the Settings I touched was just the basic configure to look for updates, and where I should look, but I saw nothing related to database

  • Yes, but what about Connection strings of App.Config Where do they point? How do they look at the end of the publication?

  • the database connection string is so: Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\DataBase\Database1.mdf;Integrated Security=True

Show 2 more comments

1 answer

2


For his 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 file Database1.mdf is overwritten in the installation;
  • Or the post creates a new file .mdf.

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

For the second, it’s App.config possibly pointing to another file. Then I find it interesting you install an extension that transforms the App.config controlled and configure the Connection string manually.

  • 1

    The problem was the same mdf file. The attribute Copy to Output Directory was Copy always. Vlw

Browser other questions tagged

You are not signed in. Login or sign up in order to post.