目前我正在部署WCF服務,實體框架訪問sqlite數據庫。該服務託管在窗口服務下。部署完成後,該服務已創建。我可以從其他機器訪問WSDL頁面。但是,我無法通過EF從數據庫獲取數據。當它處於開發環境時,所有工作。在部署到其他macgine之後,當我使用相同的查詢時,它會引發錯誤:無法找到或加載已註冊的.Net Framework數據提供程序。用實體框架部署WCF服務的問題
我認爲這個問題會涉及到sqlite的東西。我在「遠程」機器上安裝了.NET Framework 4.5和System.data.SQLite,但我仍然無法工作。有誰知道這個問題的原因?感謝您提前提供任何幫助。
此外,我是否需要在代碼中初始化DbProviderFactory以便在app.config文件中使用它?如果是這樣,哪裏應該是適當的地方插入它們?
這裏是窗口服務我的app.config文件:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
</configSections>
<system.data>
<DbProviderFactories>
<remove invariant="System.Data.SQLite"/>
<add name="SQLite Data Provider" invariant="System.Data.SQLite" description=".Net Framework Data Provider for SQLite"
type="System.Data.SQLite.SQLiteFactory, System.Data.SQLite, Version=1.0.84.0, Culture=neutral, PublicKeyToken=db937bc2d44ff139" />
</DbProviderFactories>
</system.data>
<system.web>
<compilation debug="true" />
</system.web>
<!-- When deploying the service library project, the content of the config file must be added to the host's
app.config file. System.Configuration does not support config files for libraries. -->
<system.serviceModel>
<services>
<service behaviorConfiguration="ServBehave" name="iPhysio_Wcf_Service.Service">
<host>
<baseAddresses>
<add baseAddress="http://86.163.77.253:8733/iPhysio_Wcf_Service/Service/" />
</baseAddresses>
</host>
<endpoint address="soapService" binding="basicHttpBinding" contract="iPhysio_Wcf_Service.IService" />
<endpoint address="XMLService" behaviorConfiguration="restPoxBehavior" binding="webHttpBinding" contract="iPhysio_Wcf_Service.IService" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="ServBehave">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="false" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<!--Behavior for the REST endpoint for Help enability-->
<behavior name="restPoxBehavior">
<webHttp helpEnabled="true" />
</behavior>
</endpointBehaviors>
</behaviors>
</system.serviceModel>
<connectionStrings>
<add name="iPhysioAndroidDBEntities1" connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SQLite;provider connection string='data source="C:\Users\SiuWai\Desktop\iPhysioAndroidDB"'" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>
您是否在另一臺機器上安裝了SQLite的相同版本1.0.84.0?你也可以嘗試從這裏的解決方案:http://stackoverflow.com/questions/1875134/c-sharp-failed-to-find-or-load-the-registered-net-data-provider-error –
我試過這個解決方案,它不起作用。 –
你已經嘗試了這個解決方案,並且檢查了'System.Data.SQLite.dll'在遠程機器上的解決方案的'bin'文件夾中? (也許'msvcr100.dll'以及另一個答案中提到的那樣。) –