SQLite database in memory

Mar 2, 2015 at 9:49 PM
I wonder if it is possible to make Vita support SQLite databases in memory. What needs to be done is never close the connection to the database, as that will actually delete it.

I noticed that the DbConnectionMode property of OperationContext can be set to KeepOpen, but that isn't enough. It's a property of the session, but the creation of the database happens in EntityApp.ConnectTo() before opening a session. And there the connection is always opened and closed, which won't work for an in-memory DB.
Mar 3, 2015 at 12:06 AM
is this always-open connection should be single connection? I mean, what about you open connection before you init Vita app, then init/connect the app using the same connection string, so the app internally opens/closes it, while you keep it always open outside the app, in some singleton?
Mar 3, 2015 at 3:11 PM
I'm not completely sure, but I think if you open several SQLite connections in memory, each one will create its own database. I don't see why it would limit you to a single DB in memory. So the only way to get access to a given memory DB is to get the first (and only) connection that created it.

If the connection is opened by the client before initializing the Vita app, he should pass the connection itself to Vita, not the connection string. It is also OK to pass to Vita a connection string and leave Vita open it, but in both cases Vita should never close and reopen this connection as it would actually delete the DB and create an empty one.
Mar 3, 2015 at 6:22 PM
After finding this:
  • I see what you mean. Let me think about this. Seems like a valid case, but very specific for one provider, need to think how to inject this behavior into general infrastructure