現在、SQLite データベースにアクセスするエンティティ フレームワークを使用して WCF サービスを展開しています。サービスはウィンドウ サービスでホストされています。デプロイしたら、サービスが作成されました。他のマシンから WSDL ページにアクセスできます。ただし、EF を介してデータベースからデータを取得できません。開発環境下ではすべて動作します。他の macgine に配置した後、同じクエリを使用すると、エラーがスローされます。
この問題は sqlite スタッフに関連していると思いました。「リモート」マシンに .NET Framework 4.5 と System.data.SQLite をインストールしましたが、まだ動作しません。この問題の理由を知っている人はいますか?事前に助けてくれてありがとう。
また、app.config ファイルで使用するために、コードで DbProviderFactory を初期化する必要がありますか? もしそうなら、それらを挿入する適切な場所はどこですか?
ウィンドウ サービスの 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>