C# 实体框架部署问题
实体框架对我来说是新的,我按照下面的示例使用实体框架创建wcf服务 很简单,所有的东西都是自动生成的,我的数据库位于我的app_数据文件夹中。所以在VisualStudio中运行go-it之后,我想发布并部署到IIS服务器 但当我尝试在服务器上运行它时,它会返回这个错误C# 实体框架部署问题,c#,wcf,entity-framework,mdf,C#,Wcf,Entity Framework,Mdf,实体框架对我来说是新的,我按照下面的示例使用实体框架创建wcf服务 很简单,所有的东西都是自动生成的,我的数据库位于我的app_数据文件夹中。所以在VisualStudio中运行go-it之后,我想发布并部署到IIS服务器 但当我尝试在服务器上运行它时,它会返回这个错误 The underlying provider failed on Open. at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boo
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)
基础提供程序在打开时失败。
位于System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(布尔openCondition、DbConnection StoreConnectionOpen、DbConnection originalConnection、字符串例外代码、字符串尝试操作、布尔和CloseStoreConnectionUnfailure)
位于System.Data.EntityClient.EntityConnection.Open()处
在System.Data.Objects.ObjectContext.EnsureReconnection()中
位于System.Data.Objects.ObjectQuery`1.GetResults(可为null`1 forMergeOption)
位于System.Data.Objects.ObjectQuery`1.System.Collections.Generic.IEnumerable.GetEnumerator()
位于System.Collections.Generic.List`1..ctor(IEnumerable`1集合)
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>
我没有改变任何东西,也不知道要改变什么
我错过了什么?此错误来自何处,我应该更改什么来解决此问题?当您在本地计算机上工作时,您的数据库由SQLExpress托管,当您将其部署到服务器时,您需要一个数据库服务器来托管数据库,这就是用服务器名替换。\SQLExpress的地方。是否存在内部异常?您的服务器是否也有SQL Express?如果没有,请从连接字符串中删除\SQLEXPRESS…我尝试删除\SQLEXPRESS,但它也不起作用。请将\SQLEXPRESS替换为(local)并重试。是的,但这可能是LocalDB,但仍然需要SQL Express。LocalDB是MS用于开发的,您应该在服务器上使用“完整”SQL-(Express-)DB…在服务器环境中,您可能希望将DB文件移出app_数据文件夹