6

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

3
  • 1
    Does the user you're using to connect have write access to the database? Can you connect and write to the database using Management Studio (or equivalent)? Commented Jun 28, 2010 at 13:48
  • Hmmm. I'm not specifying credentials of any kind -- didn't specify Windows auth or Forms auth. I can connect and write to the database on my local machine, of course. I will try connecting on the web server. Commented Jun 28, 2010 at 13:57
  • 1
    From my understanding, Sqlite doesn't have Windows auth or Forms auth. It's just a single-file database, no services, no authentication. Am I mistaken? Commented Jun 28, 2010 at 18:40

1 Answer 1

4

Turns out the problem was IIS security settings. I had to turn on script write access, and magically it started working.

Sign up to request clarification or add additional context in comments.

3 Comments

I've run into the same problem. Where did you turn "script write access" on? I looked in the handlers, but there I can choose between "write" and "script", but not both (radio buttons).
I figured it out. It's the Windows level write permission on the file system for the IIS user (IIS_IUSRS) which in my case could be configured via the hosts "WebsitePanel". Maybe it can also be configured via FTP (chmod) but I didn't try that.
@LouisSomers: You should add your comment as an answer to this question.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.