---edit--- Is there any additional information I can give to help solve this problem?
I'm trying to get up and running with a Sqlite and Entity Framework within a .NET WCF web service.
When I try to save anything to the database, I'm getting the error "attempt to write a readonly database". Here's the full error information:
System.Data.EntityException: An error occurred while starting a transaction on the provider connection. See the inner exception for details.
---> System.Data.SQLite.SQLiteException: Attempt to write a read-only database
Attempt to write a readonly database
at System.Data.SQLite.SQLite3.Reset(SQLiteStatement stmt)
at [snip]........................................................> at System.Data.EntityClient.EntityConnection.BeginDbTransaction(IsolationLevel isolationLevel) at System.Data.Common.DbConnection.BeginTransaction() at System.Data.EntityClient.EntityConnection.BeginTransaction() at System.Data.Objects.ObjectContext.SaveChanges(Boolean acceptChangesDuringSave) at System.Data.Objects.ObjectContext.SaveChanges() at ...
Here's my EF configuration inside Web.config (with line breaks for easier reading):
<connectionStrings>
<add
name="FooEntities"
connectionString="metadata=res://*/FooDataModel.csdl|
res://*/FooDataModel.ssdl|
res://*/FooDataModel.msl;
provider=System.Data.SQLite;
provider connection string='data source=C:\domains\myfoosite.com\wwwroot\FooService\Foo.sqlite'"
providerName="System.Data.EntityClient" />
<connectionStrings>
Why am I receiving this error? Why is the database read-only?
Some things I've tried:
Ensured the directory and file is write-able by the web service. (I've tried writing plain text files to the same directory as a test.)
I've added the 'read only=False' to the connection string.
Turns out the problem was IIS security settings. I had to turn on script write access, and magically it started working.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With