SQL Server 复制和 EDM
为了实现高可用性,我们公司正在添加新的 Web 服务器和 sql 服务器。我们将进行 P2P 复制以使两个 SQL 服务器保持一致。但是,我们在应用程序中使用 EDM,并且它基于现有服务器。如果我们添加另一个 SQL 服务器,我是否需要为第二个数据库创建另一组 EDM。维护 2 个 edmx 文件将是一场噩梦。将来出于可扩展性的目的,我们可能会添加另一个 SQL 服务器。必须有一种比为每个 SQl 服务器使用单独的 EDMX 文件更好的方法。此外,对于使用 EDM 访问数据库的现有代码,我应该如何修改它,以便它选择正确的数据库,从而选择 EDM。目前,我有这样的代码:
using (var context = new MyCOmpanyModel.MyCompanyEntities()) { .... }
我不想在访问 EDM 的每个页面上更改此设置。必须有更好的方法来选择 SQL 服务器(或实体)并将它们设置在基本页面类或类似的东西中。
任何帮助将不胜感激。
For high availability, our company is adding a new webserver and sql server. We will be doing P2P replication for making the two SQL servers consistent. However, we are using EDM in our application and it is based on the existing server. If we add another SQL server, do I need to create another set of EDM for the second database. Maintaining 2 edmx files will be a nightmare. And may be in future for scaibility purposes we add another SQL server. There must be a better way then having a separate EDMX file for each SQl server. Furthermore, for the already existing code that accesses the database using EDM, how should I modify it so that it selects the correct database and hence it's EDM. Presently, I have code like:
using (var context = new MyCOmpanyModel.MyCompanyEntities()) { .... }
I don't want to change this on every page which accesses EDM. There must be a better way of selecting the SQL server (or Entities) and setting them may be in a base Page class or anything like that.
Any help will be appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
听起来您将在托管具有相同架构的数据库的相同数据库服务器版本之间复制数据 = 无需更改 EDM,唯一需要的更改应该是第二个 Web 服务器的连接字符串。
我想知道你为什么选择这个解决方案?恕我直言,为了实现高可用性,公司通常会为数据库采用故障转移集群(主动/被动),并为 Web 服务器采用负载平衡。 Web 服务器负载平衡对客户端是透明的,故障转移集群对 Web 服务器是透明的。故障转移集群使用共享 NAS 或 SAN 存储(具有自己的高可用性功能,如 RAID 阵列和热插拔)。在主动/被动集群的情况下,您应该只需要主动服务器的 SQL Server 许可证(如果最近没有更改)。
It sounds like you are going to replicate data between same database server versions hosting the database with the same schema = there is no need to change EDM the only needed change should be connection string for the second web server.
I'm wonder why did you choose this solution? Imho to achieve high availability companies usually go to Failover clustering (active/passive) for a database and load balancing for a web server. Web server load balancing is transparent to clients and failover clustering is transparent to web server. Failover cluster uses shared NAS or SAN storage (with its own high availability features like RAID arrays and hot swaps). In the scenario of active/passive cluster you should require only SQL server licenses for active server (if this haven't changed recently).
感谢您的回复。所以这就是您的建议:
我不想将上述检查服务器代码放在几乎每个页面上。如果以后网络中再增加一台sql server,那就很头疼了。有没有更好的方法可以在应用程序中设置服务器连接字符串或 ObjectContext obj 一次,然后就忘记它。
关于您对数据库服务器进行集群的建议,集群的成本很高。它需要额外的硬件和软件。 p2P 复制似乎并不那么昂贵。不过,谢谢你的建议。
Thanks for the reply. So this is what you are suggesting:
I don't want to put the above check server code on almost every page. It will be a big headache if we add one more sql server to the netwrok later. Is there a better way of setting the server connectionstring or the ObjectContext obj once in the application and just forget about it.
Regarding your suggestion doing clustering for the database server, clustering is expensive. It requires additional hardware and software. p2P replication doesn't seem to be that expensive. However, thanks for the suggestion.