Fixed AutoSession bug (fails when using thread-local DB and NamedDB)