Problem using SQLite :memory: with NHibernate

前端 未结 9 1112
春和景丽
春和景丽 2020-12-02 08:28

I use NHibernate for my dataacess, and for awhile not I\'ve been using SQLite for local integration tests. I\'ve been using a file, but I thought I would out the :memory: o

9条回答
  •  暗喜
    暗喜 (楼主)
    2020-12-02 08:57

    I had similar problems that lasted even after opening the ISession as stated above, and adding "Pooling=True;Max Pool Size=1" to my connection string. It helped, but I still had some cases where the connection would close during a test (usually right after committing a transaction).

    What finally worked for me was setting the property "connection.release_mode" to "on_close" in my SessionFactory configuration.

    My configuration in the app.config file now look likes this:

      
        
        
          testSqlLiteDB
          NHibernate.Driver.SQLite20Driver
          NHibernate.Connection.DriverConnectionProvider
          on_close
          NHibernate.Dialect.SQLiteDialect
          NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle
          true=1;false=0
        
      
    

    Hope it helps!

提交回复
热议问题