开发者

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].............................................开发者_Python百科...........> 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜