title: Entity Framework "The underlying provider failed on Open" - Cassini vs IIS
body: <p>I have a service that uses EF to retrieve data from a SQL database.</p>
  
  <p>The EF model is in a class library. In the class library the connection is configured as:</p>
  
  <pre><code>      &lt;add name="APIC2CEntities"
       connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MYSERVER;initial catalog=MYDB;user id=MYUSER;password=THEPASSWORD;multipleactiveresultsets=True;App=EntityFramework&amp;quot;"
       providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>This class library is referenced by a WCF service project. In webconfig I control the EF connection with:</p>
  
  <pre><code>      &lt;add name="APIC2CEntities"
       connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string=&amp;quot;data source=MYSERVER;initial catalog=MYDB;user id=MYUSER;password=THEPASSWORD;multipleactiveresultsets=True;App=EntityFramework&amp;quot;"
       providerName="System.Data.EntityClient" /&gt;
  </code></pre>
  
  <p>When my service is running in Cassini the data is retrieved correctly. When the service is running under IIS (Windows XP) the connection fails with the following exception:  </p>
  
  <blockquote>
    <p><strong>The underlying provider failed on Open</strong>  </p>
  </blockquote>
  
  <p>with an inner exception telling me:  </p>
  
  <blockquote>
    <p><strong>{"A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)"}</strong>  </p>
  </blockquote>
  
  <p>I understand that Cassini is running under my logged in account, and that IIS is running under the IUSR_MYMACHINE account, but my connection is not trusted, so this <em>shouldn't</em> matter...</p>
  
  <p>How else might an EF connection be manipulated or controlled differently between IIS and Cassini?</p>
  
  <p>Thanks,<br>
  Mark</p>