سؤال

Entity Framework is new to me i follow the example below to create a wcf service with entity framework.

Introduction for Entity Framwork for Beginner

It is pretty simply, all the thing was like auto generated, my database was located in my app_data folder. So after go it running in visual studio, I want to publish and deployment to IIS server.

But when I try to run it in server, it return me this error

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)

here is my connectionstring in web.config

<connectionStrings>
    <add name="BPMCommonEntities" connectionString="metadata=res://*/BPMCommonDB.csdl|res://*/BPMCommonDB.ssdl|res://*/BPMCommonDB.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=.\SQLEXPRESS;attachdbfilename=|DataDirectory|\BPMCommon.mdf;integrated security=True;user instance=True;multipleactiveresultsets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
</connectionStrings>

I havent change anything in it, and doesn't know what to change either.

What am I missing? where is this error coming from, what should i change to fix this?

هل كانت مفيدة؟

المحلول

When you work on your local machine, you have SQLExpress host your database, and when you deploy it to server, you need a database server to host your database, and that's where you replace the .\SQLExpress with your server name.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top