I changed a dataset based approach to my sqlite database to one using the Entity Framework. I created the entities using Visual studio 2008's wizard and had the connection string stored in the app.config. A client program then communicates through WCF with the database. This works well on the development computer when I host the WCF service in a console application. After hosting the service in IIS7 on the remote computer I get the error: "The underlying provider failed on open". It is generated the first time a read operation is attempted from the database.
The autogenerated connection string is:
<add name="xPMDbEntities" connectionString="metadata=res://*/PM_EDM.csdl|
res://*/PM_EDM.ssdl|
res://*/PM_EDM.msl;
provider=System.Data.SQLite;
provider connection string="
data source=G:\PMPersistence\xPMDb.s3db""
providerName="System.Data.EntityClient" />
(I broke up the string in a few lines to make it more readable).
On the server this is not working, even if I locate the database in the exact same location as on the development computer. Does anything of the rest of the connection string, (of which I do not understand the first thing) need to be edited too? A link to a good resource about how to construct EF connection strings would be very helpful too!
EDIT: I also added the section below to the web.config file:
<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"/>
</DbProviderFactories>
</system.data>
This seems to work (Thomas suggests it should be located in the machine.config file) as before I added this entry I got an error saying that System.Data.SQLite could not be found.
EDIT2: I installed the System.Data.SQLite dll on the server rather than just xcopying the dll to the BIN directory. Both the machine.config in the Framework/Config and Framework64/Config folders now have the above DbFactory entry. It does not make a diference (unless I have to restart the server??)