Efcore: Microsoft.Data.Sqlite: Feature request: tracing, debugging

Created on 15 Oct 2017  路  5Comments  路  Source: dotnet/efcore

I'd like to be able to get some debug output of what's actually being sent to the database, especially when using an ORM like Dapper. I suspect you could add some strategic Trace.Write calls before calling sqlite3.raw.

area-adonet-sqlite blocked customer-reported good first issue type-enhancement

Most helpful comment

Workaround

You can easily leverage SQLite's native tracing (via SQLitePCL.raw):

SQLitePCL.raw.sqlite3_trace(
    connection.Handle,
    (_, statement) => Trace.WriteLine(statement, "SQLite"),
    null);

All 5 comments

Putting this on the backlog. This should be done using DiagnosticSource/DiagnosticListener. These are the event APIs that are now being used across all .NET.

Workaround

You can easily leverage SQLite's native tracing (via SQLitePCL.raw):

SQLitePCL.raw.sqlite3_trace(
    connection.Handle,
    (_, statement) => Trace.WriteLine(statement, "SQLite"),
    null);

Thanks for the workaround - that'll help for now.

Commenting again after hitting another situation where this'd be useful. I can't seem to get the workaround to work in .NET Core - I suspect I'm doing something really silly because I can't get the SQLitePCL type to be found in VS2017.

Edit: I was using Microsoft.Data.Sqlite 1.1.1, it worked after upgrading to some preview (!) release in the 2.1.0 series.

Was this page helpful?
0 / 5 - 0 ratings