Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sqlite .NET and Entity Framework - "attempt to write a readonly database"

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

like image 485
Judah Gabriel Himango Avatar asked Jun 28 '10 05:06

Judah Gabriel Himango


1 Answers

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

like image 107
Judah Gabriel Himango Avatar answered Nov 15 '22 12:11

Judah Gabriel Himango