---编辑---
有没有其他信息可以提供,以帮助解决这个问题?
我正在尝试在.NET WCF Web服务中使用Sqlite和Entity Framework。但是,当我尝试将任何内容保存到数据库时,出现了错误“尝试写入只读数据库”。以下是完整的错误信息:
System.Data.EntityException: 在提供程序连接上启动事务时发生错误,请参见内部异常的详细信息。 ---> System.Data.SQLite.SQLiteException: 尝试写入只读数据库 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 ...
下面是我在Web.config中的EF配置(为了更容易阅读,添加了换行符):
我正在尝试在.NET WCF Web服务中使用Sqlite和Entity Framework。但是,当我尝试将任何内容保存到数据库时,出现了错误“尝试写入只读数据库”。以下是完整的错误信息:
System.Data.EntityException: 在提供程序连接上启动事务时发生错误,请参见内部异常的详细信息。 ---> System.Data.SQLite.SQLiteException: 尝试写入只读数据库 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 ...
下面是我在Web.config中的EF配置(为了更容易阅读,添加了换行符):
<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>
我为什么会收到这个错误?为什么数据库是只读的?
我尝试过以下几件事情:
确保Web服务可以将目录和文件写入(我已经尝试编写普通文本文件到同一目录作为测试)。
我在连接字符串中添加了“read only=False”。