目前我正在使用访问 sqlite 数据库的实体框架部署 WCF 服务。该服务托管在窗口服务下。部署后,服务就创建好了。我可以从其他机器访问 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="C:\Users\SiuWai\Desktop\iPhysioAndroidDB"'" providerName="System.Data.EntityClient" />
</connectionStrings>
</configuration>