5

I have managed to get an XAF application into the Windows Store via the Desktop Bridge.

When a user installs my software from the Windows Store and then chooses to uninstall, I want them to have the option to completely uninstall the software including the database. So that they won't have any problem should they later decide to re-install?

Currently, the UWP uninstall does not give an option to delete the database ( or even explain how to delete it ) Thus the user may be tempted to delete the data files via Windows Explorer - which still leaves some instance of LocalDB maintaining an entry in its list of databases.

Thus on a second install after deleting the database files, the UWP program displays the error

"Login failed for user" 

As explained in this question

My connection string is using

(localdb)\mssqllocaldb

How do I automate removing the database and memory of it completely?

i.e What uninstall event can I use, What do I override where?

I can't see any executable code in the Desktop Bridge itself.

At the moment I think I may need to put "Run This Before You Uninstall" option in the actual program.

Or perhaps as a workaround, I should code a Clean Up handler for the "Login failed for user" error.

This issue is related

I am using Entity Framework 6.2 and .Net Framework 4.7.2

The Bridge Project is using Windows 10, version 1809, Build 17763 ( Min and Target)

Jeroen Heier
  • 3,520
  • 15
  • 31
  • 32
Kirsten
  • 15,730
  • 41
  • 179
  • 318
  • Do you mean that you want to remove database within uwp? – Nico Zhu Dec 17 '18 at 07:24
  • @NicoZhu-MSFT Yes I want an option to do that. Note from the other question just deleting the database and log files is not enough. – Kirsten Dec 17 '18 at 09:16
  • There seem to be some hints at https://stackoverflow.com/questions/15318843/localdb-how-do-you-delete-it – Kirsten Dec 18 '18 at 20:54
  • The original database will not cause **Login failed for user**, Have you check another issue about this? – Nico Zhu Dec 19 '18 at 02:58
  • @NicoZhu-MSFT Yes and things are worse now https://stackoverflow.com/questions/53877961/the-underlying-provider-failed-on-open-after-deleting-database-files-and-sqlloca – Kirsten Dec 21 '18 at 01:16
  • Is dropping all of the tables sufficient? – Tiago Martins Peres Dec 23 '18 at 09:27
  • 1
    @tiagoperes that would not remove the database completely which is what I want. It could be a work around for the reinstall issue though. – Kirsten Dec 23 '18 at 21:02
  • https://learn.microsoft.com/en-us/uwp/api/windows.applicationmodel.packageuninstallingeventargs – Kirsten Dec 23 '18 at 21:14
  • https://stackoverflow.com/questions/53909226/what-localdb-instance-does-desktop-bridge-use – Kirsten Dec 24 '18 at 04:42
  • @KirstenGreed probably you don't really need a solution as drastic to get needed results / fix the problem you're going though. Therefore, my suggestion is to adapt the current question and drop the tables. If you still encounter problems later on the path with this solution, then remove the database will be the next step. – Tiago Martins Peres Dec 24 '18 at 12:46
  • @tiagoperes On what event would i do that? – Kirsten Dec 24 '18 at 19:47

1 Answers1

0

See Getting Started with EF Core on Universal Windows Platform (UWP) with a New Database. It introduces use of migrations. Migrations are designed to help you change your database design and implement the changes in production. Migrations can be frustrating though because Microsoft has not documented the feature thoroughly. There is a list somewhere of the migration features not supported for SQLite; it is important to know about that from the beginning.

Rinzler786
  • 109
  • 1
  • 11