Charles LAU
Charles LAU

Reputation: 281

Issue with deploying WCF Service with entity framework

Currently I am deploying the WCF service with entity framework accessing the sqlite database.The service is hosted under window service. After I deployed it, the service has been created. I can access the WSDL page from other machine. However, I cannot get data from the database through EF. All work when it is under development environment. After deployment to other macgine, when I use the same query, it throws an error: fail to find or load the registered .Net Framework Data Provider.

I thought this issue would be relating to the sqlite stuffs. I have installed .NET framework 4.5 and the System.data.SQLite in the "remote" machine, but I still doesn't work. Does anyone know the reason for this issue? Thanks for any help in advance.

Also, Do I need to initialise the DbProviderFactory somewhete in my code in order to use it in app.config file? If so, where should be appropriate place to insert them?

Here is my app.config file of the window service:

   <?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>

Upvotes: 0

Views: 986

Answers (1)

nkvu
nkvu

Reputation: 5851

I'm not sure if this is it but your connection string in the config:

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;'"

Seems to be referencing a C:\Users location. Is that where the SQLite database is deployed on your remote server?

Other than that, the <system.data> section with the DbProviderFactories stuff looks OK to me and I don't think there is anything wrong there (or anything which differs from the literature on the net about how to do this)...sorry, no expert on using SQLite in .NET - I've only done it a couple of times naively as an example/to learn.

Upvotes: 1

Related Questions