簡體   English   中英

使用實體框架部署WCF服務的問題

[英]Issue with deploying WCF Service with entity framework

目前,我正在使用訪問sqlite數據庫的實體框架部署WCF服務。該服務托管在window服務下。 部署后,服務已創建。 我可以從其他機器訪問WSDL頁面。 但是,我無法通過EF從數據庫中獲取數據。 一切都在開發環境下進行。 部署到其他Macgine后,當我使用相同的查詢時,它引發錯誤:無法找到或加載已注冊的.Net Framework數據提供程序。

我認為這個問題與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=&quot;C:\Users\SiuWai\Desktop\iPhysioAndroidDB&quot;'" providerName="System.Data.EntityClient" />
  </connectionStrings>
</configuration>

我不確定是否是這樣,但是您在配置中的連接字符串是:

connectionString="metadata=res://*/DataModel.csdl|res://*/DataModel.ssdl|res://*/DataModel.msl;provider=System.Data.SQLite;provider connection string='data source=&quot;C:\Users\SiuWai\Desktop\iPhysioAndroidDB&quot;'"

似乎正在引用C:\\ Users位置。 那是在遠程服務器上部署SQLite數據庫的地方嗎?

除此之外,帶有DbProviderFactories內容的<system.data>部分在我看來還可以,而且我認為那里沒有任何問題(或與網絡上有關如何執行此操作的文獻有所不同的地方)...抱歉,沒有在.NET中使用SQLite的專家-作為示例,我只是天真地做過幾次。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM