I am using SQL Azure as database with code first technique of Entity framework 4.1. I’m accessing EF from WCF as middle tier and providing the service reference to ASP.NET MVC 3.
The relational scenario in EF is A->B->C so as usual I tried to get A including B including C with few possibilities:
db.A.Include("B").Include("B.C")
db.A.Include("B").Include("C")
But in the Service itself running perfect. Since adding the reference to the web application it attempts to serialize and throws the exception below. I tried to make true-false lazy loading also without success.
"The underlying connection was closed: The connection was closed unexpectedly"
Stack Trace found:
at System.Net.HttpWebRequest.GetResponse() at
System.ServiceModel.Channels.HttpChannelFactory.
HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout)
I visited this page to resolve, and added the suggested attributes in web.config. Now I’m suddenly getting error:
The server did not provide a meaningful reply; this might be caused by
a contract mismatch, a premature session shutdown or an internal
server error
I thought it might be issue of some tag/atrribute mismatch in client and service web.configs but everything is right there. One thing I could not get to passing the List of objects with loading of its entire cllection properties, from wcf service to web application is found very heavy and low in performance. still facing the above issues to get the loaded list at web application in above explained architecture. can some body help here….
hey Thanks Kirk Broadhurst
, By this I could track the Issue. and searche around it. I got the solution. I added this class in my project
And Added just :
[ReferencePreservingDataContractFormat]as an attribute with the method definition where i wanted to use the “Include”. thats it worked for me.This might be helpful for other needy people.