实体框架:"的ProviderName"在连接字符串须─所有的突然? [英] Entity Framework: "ProviderName" in connection string required- all of the sudden?

查看:664
本文介绍了实体框架:"的ProviderName"在连接字符串须─所有的突然?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们一直在使用实体框架,在生产环境多月了,而就在昨天开始得到错误的部分的使用我们的DbContext的子查询数据库时机器:

  

连接字符串MyConnectionString在应用程序的   配置文件不包含所需的providerName   属性

我们的问题很容易解决:我加入的providerName =System.Data.SqlClient的来对所有已部署的服务器和工作站的配置文件的连接字符串。

不过,神秘的仍然是:根据的文档

  

本的ProviderName属性是可选的,默认为   System.Data.SqlClient的。

更神秘的是为什么这开始发生突然,显然只有在一些机器上。我不知道有任何最新变化EF或.NET版本,任何SQL Server版本或供应商的变化,或任何东西。但我知道必须有件事情我已经忽略了。

.NET 4.5 EF 5.0

任何人有任何提示或见解?

解决方案

某些驱动程序组合会导致机器在一个状态,它是不明确的,应该使用哪种驱动程序,因此它需要一个明确的供应商名称。

这可能是其他一些独立的应用程序或驱动程序的安装,或自动的Windows Update跑。

作为明确与供应商的名称并没有,虽然伤害任何东西。你应该罚款将其添加;这只是在连接字符串中一些额外的字符。它不会永远需要在未来或任何改变。

We've been using Entity framework in a production environment for many months now, and just yesterday started to get errors on some machines when querying the database using our subclass of DbContext:

"The connection string 'MyConnectionString' in the application's configuration file does not contain the required providerName attribute"

Our problem is easily solved: I adding the "providerName="System.Data.SqlClient" to the connection string in the config files on all deployed servers and workstations.

However, the mystery remains: according to the documentation:

The providerName attribute is optional, and the default is "System.Data.SqlClient".

Even more mysterious is why this started happening suddenly, and apparently only on some machines. I am not aware of any recent changes in EF or .NET versions, any SQL Server version or provider changes, or anything. But I realize there has to be something I've overlooked.

.NET 4.5 EF 5.0

Anyone have any hints or insights?

解决方案

Certain driver combinations will cause the machine to be in a state where it is ambiguous which driver it should use, so it requires an explicit provider name.

It was probably some other separate application or driver install, or automatic Windows Update that ran.

Being explicit with the provider name doesn't hurt anything though. You should be fine adding it; it's only a few extra characters in your connection string. It won't ever need to change in the future or anything.

这篇关于实体框架:"的ProviderName"在连接字符串须─所有的突然?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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