Any write operation locks the entire database. You are going to have to do your identities a little different if you want to work with SQLite.
http://weblogs.asp.net/jgalloway/archive/2005/07/08/418472.aspx - Robert On Mon, Mar 22, 2010 at 9:15 AM, Dinesh <[email protected]> wrote: > Hi everyone, > When trying to use SQLite with System.Transactions > TransactionScope with the identity generator as Increment, i noticed > that i was getting an exception (given below along with code) when > NHibernate was trying to retrieve the next Identity number. This seems > to be because the new SQLite connection is doing a auto enlist of the > current transaction. From what i have heard SQLite only support single > write transaction, but should support multiple read's, so i am > surprised that i am getting a Database locked exception for a read > operation. Did anybody use SQLite with Transaction Scope in this > manner. The same Code works fine if i use a NHibernate Transaction > instead of TransactionScope > > Code Block: > using (var scope = new TransactionScope()) > { > var userRepository = > container.GetInstance<IUserRepository>(); > var user = new User(); > > userRepository.SaveOrUpdate(user); > > scope.Complete(); > } > > Exception: > 19:34:19,126 ERROR [ 7] IncrementGenerator [(null)]- could not get > increment value > System.Data.SQLite.SQLiteException: The database file is locked > database is locked > at System.Data.SQLite.SQLite3.Step(SQLiteStatement stmt) > at System.Data.SQLite.SQLiteCommand.ExecuteNonQuery() > at System.Data.SQLite.SQLiteTransaction..ctor(SQLiteConnection > connection, Boolean deferredLock) > at System.Data.SQLite.SQLiteConnection.BeginTransaction(Boolean > deferredLock) > at System.Data.SQLite.SQLiteConnection.BeginTransaction() > at System.Data.SQLite.SQLiteEnlistment..ctor(SQLiteConnection cnn, > Transaction scope) > at > System.Data.SQLite.SQLiteConnection.EnlistTransaction(Transaction > transaction) > at System.Data.SQLite.SQLiteConnection.Open() > at NHibernate.Connection.DriverConnectionProvider.GetConnection() > at NHibernate.Id.IncrementGenerator.GetNext(ISessionImplementor > session) > 19:34:20,063 ERROR [ 7] ADOExceptionReporter [(null)]- The database > file is locked > database is locked > > Regards > Dinesh > > -- > You received this message because you are subscribed to the Google Groups > "nhusers" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<nhusers%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/nhusers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "nhusers" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/nhusers?hl=en.
