we had the same issue with one of our apps. We solved it as follows:
- Add Settings file into your project, and add
MyConnectionString
string property into it - When app starts for the first time - display "Please enter your connection string" form - and let user enter his connection string. Verify it's valid and then save it into settings:
like this:
MyApp.MySettings.MyConnectionString= cs;
MyApp.MySettings.Save();
and then you can build connection string in the code as described in this How to: Build an EntityConnection Connection String
the benefit of using "Settings" file is that the framework takes care of saving/persisting it etc, and you have strongly-type code support as well.
Regarding encryption - you can encrypt it before saving into settings file, and decrypt when reading. It's straightforward I think.