与SQL Server分布式可用性组群集的EntityFramework连接 [英] EntityFramework Connections to SQL Server Distributed Availability Group Cluster

查看:76
本文介绍了与SQL Server分布式可用性组群集的EntityFramework连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们最近建立了一个分布式可用性组群集。 群集在三个不同的域/区域内具有三个不同的可用性组。一个主要读/写侦听器和另外两个具有只读副本的侦听器。

We recently built a Distributed Availability Group cluster.  The cluster has three different availability groups within three different domains/region. One primary read/write listener and two other listeners with read-only replicas.

我们计划在每个域/区域中配置使用EntityFramework构建的应用程序。我们如何配置EntityFramework连接以正确发送与主侦听器的读/写连接以及与本地侦听器的只读连接?

We plan to have an application built with EntityFramework configured in each domain/region. How would we configure EntityFramework connections to properly send read/write connections to the Primary Listener and read-only connections to the Local Listener?

是否有关于如何配置与Distributed通信的连接的文档可用性组群?

Is there documentation on how to configure connections to communicate with Distributed Availability Group clusters?

Thx

推荐答案

它是由连接意图决定。如果你想要连接转到只读副本,你的连接应该有额外的参数  ApplicationIntent = READONLY。

It is decided by the connection intent. if you want the connection to go to the read only replicas your connection should have the extra parameter ApplicationIntent=READONLY.

以下是与同一个监听器的两个不同连接的示例只读意图和其他readwrite。听众将基于
< ApplicationIntent值的连接重定向到读写(PRIMARY REPLICA)或只读(SECONDARY REPLICA)。如果您未指定应用程序意图,则将其视为读写连接,并始终点击主副本。 

the following is an example of two different connections to the same Listener one with read-only intent and other with readwrite. It is the listener that redirect the connection to the read-write (PRIMARY REPLICA) or read-only (SECONDARY REPLICA) based on the ApplicationIntent value. If you don't specify an application intent, it will be considered as a read-write connection and will always hit the Primary replica. 

<add name="MyReadWriteConn" connectionString="Data Source=MyListnerName;ApplicationIntent=READWRITE;Initial Catalog=MyDB;User ID=MyUser;Password=MyPassword" providerName="System.Data.SqlClient"/>
<add name="MyReadOnlyConn" connectionString="Data Source=MyListnerName;ApplicationIntent=READONLY;Initial Catalog=MyDB;User ID=MyUser;Password=MyPassword" providerName="System.Data.SqlClient"/>





这篇关于与SQL Server分布式可用性组群集的EntityFramework连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆