Darf Zon
Darf Zon

Reputation: 6378

The underlying provider failed on Open

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?

Upvotes: 0

Views: 3944

Answers (1)

tmesser
tmesser

Reputation: 7666

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.

Upvotes: 3

Related Questions