简体   繁体   中英

ClickOnce With Multiple app.config Files

We are getting close to a situation where we're going to have multiple users using our application, each with their own version of a SQL Database (in Azure). Their versions of the application will be the same, their Databases different. The structure of each Database will be the same for all users but they will have their own version.

I have had some success with using ClickOnce so far and would like to continue using it to publish updates to the application to all users.

I am using Entity Framework in C# and it generates it's own connection string that is stored in my app.config file. This is where I have an issue.

How would I distribute updates to each individual user, using their own Database, without overwriting their own app.config file and therefore pointing the connection string to a different (wrong) Database?

One solution I had thought of would be to not store the Entity Framework connection string in the app.config file and instead have a local copy of a SQLlite database with the string in instead. However I would have to then install this on every user's PC and this would be very time consuming.

So I am looking for a solution where I can have the same application code, with different SQL Databases updated through ClickOnce without changing wherever I store the connection string for that user.

One option would be to store the connection strings in a common central location, such as for example a network drive, that the applications connect to and retrieve the user specific settings based on some parameter, like for example the user name of the current user.

Another option would be publish an individual output package (application) for each specific user where the specific connection string is already incluced.

A third option may be to use a local embedded database that you ship with the application itself.

If you will be using EF avoid using TransactionHandler with SQL Azure databases due to bad performance. If you find more performance issues during your project please let me know to report it.

Consider using Elastic Pools for your customer databases and using Elastic jobs to easily apply updates to all those databases. You can learn more about it here .

Hope this helps.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM