David Sykes
David Sykes

Reputation: 49812

How can I create an in memory sqlite database?

I have tried SQLiteConnection(":memory:") and SQLiteConnection("sqlite::memory:") but both of these fail with 'Invalid ConnectionString format'

Upvotes: 55

Views: 37322

Answers (3)

everydayXpert
everydayXpert

Reputation: 857

I'm using this:

var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = ":memory:" };
var connection = new SQLiteConnection(connectionStringBuilder.ToString());

Upvotes: 7

murzagurskiy
murzagurskiy

Reputation: 1323

Maybe it's too late, but FullUri=file::memory:?cache=shared; is working.

It's knowledge from forum question

Upvotes: 4

Yahia
Yahia

Reputation: 70369

try

var connection = new SQLiteConnection("Data Source=:memory:");

Upvotes: 95

Related Questions