无法使用 asp.net 核心 3.1 打开 SqLiteConnection
Can't open a SqLiteConnection with asp.net core 3.1
我正在尝试将 SQLite 与 asp.net 核心 3.1 一起使用
我安装了 MS Data SQLite Core nuget 包。
当我没有在连接字符串中指定版本时,SQLiteConnection 中的服务器版本变量为空,我得到了这个错误:
System.NullReferenceException : 'Object reference not set to an instance of an object.'
但是当我指定版本时,它说不支持关键字版本...
也许这是另一个问题?
我的代码:
var connectionStringBuilder = new SqliteConnectionStringBuilder(connectionString)
{
DataSource = "./MyTestDB.db",
Mode = SqliteOpenMode.ReadWriteCreate,
Password = "Toto",
}.ToString();
using (var connection = new SqliteConnection(connectionStringBuilder))
{
connection.Open();
}
PS : 我也试过全路径...
提前感谢您阅读本文。研究了没找到答案..
我通过将 Microsoft.Data.SQLite.Core 包更改为 System.Data.SQLite.Core 解决了我的连接问题。
现在可以用了,但这仍然不能解释为什么 MS one 对我不起作用..
我找到了。 SQLite "standart" 没有加密。问题是密码。我把它取下来然后它工作了。
谢谢
问题是我包含了 Microsoft.Data.Sqlite.Core
而不是 Microsoft.Data.Sqlite
(注意缺少 .Core
)。
我正在尝试将 SQLite 与 asp.net 核心 3.1 一起使用 我安装了 MS Data SQLite Core nuget 包。
当我没有在连接字符串中指定版本时,SQLiteConnection 中的服务器版本变量为空,我得到了这个错误:
System.NullReferenceException : 'Object reference not set to an instance of an object.'
但是当我指定版本时,它说不支持关键字版本... 也许这是另一个问题?
我的代码:
var connectionStringBuilder = new SqliteConnectionStringBuilder(connectionString)
{
DataSource = "./MyTestDB.db",
Mode = SqliteOpenMode.ReadWriteCreate,
Password = "Toto",
}.ToString();
using (var connection = new SqliteConnection(connectionStringBuilder))
{
connection.Open();
}
PS : 我也试过全路径...
提前感谢您阅读本文。研究了没找到答案..
我通过将 Microsoft.Data.SQLite.Core 包更改为 System.Data.SQLite.Core 解决了我的连接问题。 现在可以用了,但这仍然不能解释为什么 MS one 对我不起作用..
我找到了。 SQLite "standart" 没有加密。问题是密码。我把它取下来然后它工作了。 谢谢
问题是我包含了 Microsoft.Data.Sqlite.Core
而不是 Microsoft.Data.Sqlite
(注意缺少 .Core
)。