简体   繁体   English

具有多个app.config文件的ClickOnce

[英]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). 我们正在接近一个局面,即将有多个用户使用我们的应用程序,每个用户都有自己的SQL数据库版本(在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. 到目前为止,我在使用ClickOnce方面已经取得了一些成功,并希望继续使用它来将应用程序的更新发布给所有用户。

I am using Entity Framework in C# and it generates it's own connection string that is stored in my app.config file. 我在C#中使用实体框架,它生成了自己的连接字符串,该字符串存储在我的app.config文件中。 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? 我如何使用他们自己的数据库将更新分发给每个用户,而不覆盖他们自己的app.config文件,因此将连接字符串指向另一个(错误的)数据库?

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. 我想到的一种解决方案是不将Entity Framework连接字符串存储在app.config文件中,而是使用SQLlite数据库的本地副本代替该字符串。 However I would have to then install this on every user's PC and this would be very time consuming. 但是,我必须将其安装在每个用户的PC上,这将非常耗时。

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. 因此,我正在寻找一个解决方案,使我可以拥有相同的应用程序代码,并通过ClickOnce更新不同的SQL数据库,而不更改我为该用户存储连接字符串的位置。

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. 如果要使用EF,请避免由于性能低下而将TransactionHandler与SQL Azure数据库一起使用。 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. 希望这可以帮助。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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