I had created a shared in-memory database using the following code, but the problem is, even I close the connection or restart the machine, the data is still available.
I didn't understand how the data is persistent and where it is physically stored.
using (SQLiteConnection database = new SQLiteConnection("file: empDB ? mode = memory & cache = shared"))
{
database.CreateTable(emp.GetType());
database.Insert(emp);
var value = database.Query<Emp>("select * from emp;select * from emp;");
}
To achieve expected behavior you could use
FullUri
syntax, e.g:Database file with name
empDB
is created in your application working directory when you use your original connection string, e.g.FullUri=file: empDB ? mode = memory & cache = shared
. This file is reused when you run the application again.