0

I'm using EntityFramework with Windows Azure platform. It works so well in LOCAL mode, but when I'm trying to run my Silverlight application on Web. I get an error:

The underlying provider failed on Open.

<configuration>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
      <add name="DomainServiceModule" preCondition="managedHandler" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </modules>
    <validation validateIntegratedModeConfiguration="false" />
  </system.webServer>
  <appSettings>
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
    <add key="ValidationSettings:UnobtrusiveValidationMode" value="WebForms" />
  </appSettings>
  <system.web>
    <httpModules>
      <add name="DomainServiceModule" type="System.ServiceModel.DomainServices.Hosting.DomainServiceHttpModule, System.ServiceModel.DomainServices.Hosting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    </httpModules>
    <customErrors mode="Off" />
    <compilation debug="true" targetFramework="4.5">
      <assemblies>
        <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
      </assemblies>
    </compilation>
    <httpRuntime requestValidationMode="4.5" targetFramework="4.5" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <pages controlRenderingCompatibilityVersion="4.5" />
    <machineKey compatibilityMode="Framework45" />
  </system.web>
  <system.serviceModel>
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <connectionStrings>
    <add name="DatabaseEntities" connectionString="metadata=res://*/Model.csdl|res://*/Model.ssdl|res://*/Model.msl;provider=System.Data.SqlClient;provider connection string=&quot;data source=lnqg2ulkjr.database.windows.net;initial catalog=BuilderDatabase;persist security info=True;user id=XXXXX;password=XXXXX;MultipleActiveResultSets=True;App=EntityFramework&quot;" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

I was checking that this is a problem in the connection string with Integrated Security but in my case I don't have that property. What could be the error?

4
  • 3
    You shouldn't put your real userid/password in connection string examples, i X'd it out for you in edit but dont forget! Oct 29, 2012 at 19:22
  • Does your model match your database? Are you sure the user/password is correct?
    – Cody
    Oct 29, 2012 at 19:30
  • @EkoostikMartin Sorry for that, I missed that!
    – Darf Zon
    Oct 29, 2012 at 19:46
  • @DoctorOreo Yes, I've tested the connection with SQL Wizard in VS2012
    – Darf Zon
    Oct 29, 2012 at 19:47

1 Answer 1

3

This error is from Entity - it has little to do with Silverlight. It happens when one of two things happen:

  • Entity tries to log in to the database you've pointed it to, and is denied permission/can't find the server/can't find the instance/has some other connection error
  • Entity successfully logs in, but can't find the data model it recognizes

The second should be very simple to check since you have a working local. If the data model on your local is the same as the data model in your 'production' environment, then that part is taken care of. If you have tables that are different, you could have some issues. This is doubly true if they are missing columns that you've coded in to Entity's data model. Entity will tolerate extra columns and extra tables in many cases, though this changes a lot based on the situation, so YMMV. However, if Entity expects something to be there and it's not, it'll crash with a quickness every time.

My larger suspicion would be that rather awesome connection string you have there. You should be able to check the InnerException on what you're getting to see the specific gripe that the database server is raising. If it isn't, I would rip that out into a console application and attempt to connect with a plain jane SqlConnection doing a simple Select count(Id) from dbo.SmallTable. This will allow you to isolate the connection problems and deal with them in a nice, restricted environment. After you've sorted through the connection issues, you can paste your connection string - now hopefully less confusing - back in and move on.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.