本文介绍了实体框架是否在SQLClient连接字符串中支持ApplicationIntent = ReadOnly的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
实体框架是否在SQLClient连接字符串中支持 ApplicationIntent = ReadOnly ?它是指对副本的只读访问功能始终可用的可用性组(SQL Server 2012).
Does Entity Framework support ApplicationIntent=ReadOnly in SQLClient connection string? It is in reference to Read-Only access on an Availability Replica feature of AlwaysOn Availability Groups (SQL Server 2012).
推荐答案
到目前为止,我发现的唯一方法是直接使用连接字符串而不是使用连接字符串名称来创建上下文.这样,您可以附加 ApplicationIntent
.
The only way I've found so far would involve creating the context using the connection string directly, instead of using a connection string name. This way you could append the ApplicationIntent
.
string connectionString = string.Format("{0}; ApplicationIntent=READONLY", ConfigurationManager.ConnectionStrings["AppContext"].ConnectionString);
using (AppContext context = new AppContext(connectionString))
{
var q = from row in context.table
select row.id;
}
这篇关于实体框架是否在SQLClient连接字符串中支持ApplicationIntent = ReadOnly的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!