ClickOnce: how to deploy a WPF application with a localDB database

This is very similar to the previous question , but I'm looking for an answer that updates it for the latest localDB and Visual Studio 2013. [ edit : this also applies to Visual Studio 2015] There is also another question similar to this one , but without an answer.

The situation is that I have a WPF application that uses LocalDB. I have a connection string in my app.config with "Data Source = (localdb) \ mssqllocaldb", the correct source directory, and some other stuff. It does not indicate the mdf file. Everything works if I create and run from release / bin or debug / bin.

When I publish using clickOnce on my dev machine, the application installs and appears on the Start menu. The problem is that when I run it, an exception is thrown, flashing the internal exceptions, the complaint seems ...

Source provider could not open Open.

Unable to attach file 'C: \ Users \ myName \ AppData ... \ myContext.mdf'as database myContext

I don’t understand what is going on here. I expected that the installed ClickOnce application would just use the connection string in app.config and then work with the existing database (localDB) / mysqllocaldb. Instead, he tries to attach the mdf file (which, by the way, does not exist) to my localDB, where I already have the database that the application uses.

, , clickonce , localdb. , MSDN. , , , .

ClickOnce , LocalDB :

  • mdf localDB, .

  • , mdf localDB ( connectionString config ).

  • ... , , , localDB mdf mdf localDB.

+4

Source: https://habr.com/ru/post/1584111/


All Articles