我有一個使用EF從SQL數據庫檢索數據的服務。實體框架「底層提供程序在打開時失敗」 - 卡西尼vs IIS
EF模型位於類庫中。在類庫中,連接配置爲:
<add name="APIC2CEntities"
connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MYSERVER;initial catalog=MYDB;user id=MYUSER;password=THEPASSWORD;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
此類庫由WCF服務項目引用。在webconfig我控制與EF連接:
<add name="APIC2CEntities"
connectionString="metadata=res://*/MyModel.csdl|res://*/MyModel.ssdl|res://*/MyModel.msl;provider=System.Data.SqlClient;provider connection string="data source=MYSERVER;initial catalog=MYDB;user id=MYUSER;password=THEPASSWORD;multipleactiveresultsets=True;App=EntityFramework""
providerName="System.Data.EntityClient" />
當我的服務是在卡西尼運行數據被正確檢索。當服務IIS(Windows XP中)下運行的連接失敗,出現以下異常:
The underlying provider failed on Open
與內部異常告訴我:
{"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)"}
我明白,卡西尼號在我的記錄中運行帳戶,並且該IIS正在IUSR_MYMACHINE帳戶下運行,但我的連接不受信任,所以此不應該問題...
EF如何以其他方式操縱或控制EF連接IIS和Cassini之間?
謝謝,
馬克
該問題似乎與EF沒有關係......您可以直接使用ADO.NET打開連接嗎? – 2011-05-03 09:17:13
所有應該處理的事項都是進程標識和用於連接的憑證 - 除了標識以外,Cassini或IIS是否正在執行都沒有區別 – BrokenGlass 2011-05-03 13:08:33