【问题标题】:In asp.net with sqlite set pragma Synchronous=Off在 asp.net 中使用 sqlite 设置 pragma Synchronous=Off
【发布时间】:2017-11-14 07:36:59
【问题描述】:

尝试通过在连接字符串中设置Synchronous=Off 来优化asp.net 应用程序中的Sqlite,但不支持关键字https://github.com/ericsink/SQLitePCL.raw/issues/147 https://github.com/aspnet/Microsoft.Data.Sqlite/issues/354

问题 #354 的底部提出了一个带有指向连接的 pragma 命令的解决方案

using (var command = connection.CreateCommand())
{
    command.CommandText = "PRAGMA foreign_keys = true;";
    command.ExecuteNonQuery();
}

尝试将此用于Synchronous https://sqlite.org/pragma.html#pragma_synchronous 但不确定在哪里/如何获得与我的 DbContext 类型对应的正确连接。

【问题讨论】:

    标签: asp.net sqlite


    【解决方案1】:

    使用如下代码下拉到 EF Core 中的 ADO.NET 连接:

    db.Database.OpenConnection();
    try
    {
        var connection = db.Database.GetDbConnection();
    
        // TODO: Use connection
    }
    finally
    {
        db.Database.CloseConnection();
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-04-15
      • 1970-01-01
      • 2012-03-29
      • 2011-05-30
      • 2015-05-16
      • 2011-05-30
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多