I have a software installation that includes a Topshelf service and an MVC4 web application. Both need to access the same LocalDb MDF. The development version runs as our users. The installed version runs as LocalSystem.
I'm trying to switch the user (Post-Install) that the installed version runs as so that network paths can be accessible, particularly if IT has prevented adding Machine permissions. If I switch both the users for the service and AppPool (load user profiles is on), and I wait for all previous sqlservr.exe instances to quit, or I explicitly delete the other users instance, I am unable to connect to the instance as the new user. I've tried copying the mdf to a new location and using that instead. I've tried creating and seeding a new mdf as the desired user. It seems no matter what I do I'm unable to connect to the instance. I usually get error 50. Switching back to LocalSystem works fine.
Another oddity is that if I explicitly create the named instance using "sqllocaldb create NamedInstance -s", there will be 2 instances with the same name listed by "sqllocaldb info"! One of those instances, despite being listed, cannot be interacted with. Getting info, stopping, starting, or deleting all return that the instance does not exist after I've removed the other instance with the same name.
NOTE: I can easily switch users on my VMs, so the problems seem related to either doing it on the same machine used to develop and Debug (thus running LocalDB instance through Visual Studio host) or having full SQL Server 2008 and 2012 installed.