":memory:"で指定して ";mode=memory;cache=shared"; を付けて使う
public abstract class SqliteBase { public string ConnectionString; protected SqliteBase() { SQLiteConnectionStringBuilder builder = new SQLiteConnectionStringBuilder { DataSource = ":memory:", ForeignKeys = true, DefaultTimeout = 3, DateTimeKind = DateTimeKind.Utc, Pooling = false }; ConnectionString = builder.ConnectionString + ";mode=memory;cache=shared"; } private DbConnection _MemoryConnection; protected DbConnection GetConnection() { try { if (_MemoryConnection == null) { _MemoryConnection = new SQLiteConnection(ConnectionString); _MemoryConnection.Open(); } DbConnection dbConnection = new SQLiteConnection(ConnectionString); dbConnection.Open(); return dbConnection; }