【发布时间】:2013-08-20 13:08:49
【问题描述】:
实体框架对我来说是新的,我按照下面的示例使用实体框架创建 wcf 服务。
Introduction for Entity Framwork for Beginner
这很简单,所有的东西都是自动生成的,我的数据库位于我的 app_data 文件夹中。所以在 Visual Studio 中运行后,我想发布并部署到 IIS 服务器。
但是当我尝试在服务器中运行它时,它返回了这个错误
The underlying provider failed on Open.
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)
at System.Data.EntityClient.EntityConnection.Open()
at System.Data.Objects.ObjectContext.EnsureConnection()
at System.Data.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
at System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable<T>.GetEnumerator()
at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
这是我在 web.config 中的连接字符串
<connectionStrings>
<add name="BPMCommonEntities" connectionString="metadata=res://*/BPMCommonDB.csdl|res://*/BPMCommonDB.ssdl|res://*/BPMCommonDB.msl;provider=System.Data.SqlClient;provider connection string="data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\BPMCommon.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework"" providerName="System.Data.EntityClient" />
</connectionStrings>
我什么都没改,也不知道改什么。
我错过了什么?这个错误来自哪里,我应该改变什么来解决这个问题?
【问题讨论】:
-
有内部异常吗?
-
您的服务器是否也有 SQL Express?如果没有,请从连接字符串中删除 \SQLEXPRESS...
-
我试过删除 \SQLEXPRESS 它也不起作用。
-
将 \SQLEXPRESS 替换为 (local) 并重试。
标签: c# wcf entity-framework mdf