C# 如何创建内存中的 sqlite 数据库?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9173485/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How can I create an in memory sqlite database?
提问by David Sykes
I have tried SQLiteConnection(":memory:")and SQLiteConnection("sqlite::memory:")but both of these fail with 'Invalid ConnectionString format'
我已经尝试过SQLiteConnection(":memory:"),SQLiteConnection("sqlite::memory:")但是这两个都因“无效的 ConnectionString 格式”而失败
采纳答案by Yahia
try
尝试
var connection = new SQLiteConnection("Data Source=:memory:");
回答by gek0n
Maybe it's too late, but FullUri=file::memory:?cache=shared;is working.
也许为时已晚,但FullUri=file::memory:?cache=shared;正在发挥作用。
回答by everydayXpert
I'm using this:
我正在使用这个:
var connectionStringBuilder = new SQLiteConnectionStringBuilder { DataSource = ":memory:" };
var connection = new SQLiteConnection(connectionStringBuilder.ToString());

