You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We currently cache the compilation at the DbCommand level. We could lift it to an opened connection without this. With this we could do it across close and re-open.
Nice... If you work on prepared statements, consider also persisting them across pooled open/close, otherwise they're useless in short-lived connection scenarios.
I decided this probably isn't a breaking change since we can make the behavioral breaking changes as part of #13826, and add pooling later to improve performance.
@ajcvickers: A simple question I'm sure but ... in the released version I am supposed to call SqliteConnection.ClearPool( SqliteConnection), where do I get the SqliteConnection from? DbContext.Database.GetDbConnection() returns a DbConnection instead.
Edit: the parameter type to InitializeDbConnection in SqliteRelationalConnection.cs would seem to suggest that the DbConnection can just be cast down to an SqliteConnection, is that correct? Would be nice to note this in the Breaking Changes document.
The breaking change was that connection pooling results in the file being locked for longer than before. To unlock the file you need to call ClearPool. In my case when my UI program is in the background for a long time then I want to release the file so that OneDrive can copy it. The breaking change page talks about calling SqliteConnection.ClearPool but doesn't say how to get the SqliteConnection.
Fair enough. I guess the reason I was confused was I assumed that SqliteConnection would be provided by the sqlite engine rather than by EF Core, so it wasn't a natural conclusion for me that it would be derived from an EF class.
I'm not trying to be hard-headed here. I know there is a breaking change note for EF, thanks, that's great. I'm just giving you the feedback that it would be nice if the breaking change note said "The SqliteConnection can be obtained by casting DbContext.Database.GetDbConnection() to SqliteConnection". It would save time poking around in the source code and bugging you nice folks in an attempt to figure it out. I know it's obvious to you but it wasn't very obvious to me for whatever reason.
Activity
divega commentedon May 16, 2018
@bricelam would this also be an excuse to implement auto-prepared statements (assuming it isn’t implemented yet)?
bricelam commentedon May 16, 2018
We currently cache the compilation at the DbCommand level. We could lift it to an opened connection without this. With this we could do it across close and re-open.
divega commentedon May 16, 2018
Cool! Once we have that, I think implementing auto-prepared commands (like Npgsql) could give us another boost.
Cc @roji
roji commentedon May 16, 2018
Nice... If you work on prepared statements, consider also persisting them across pooled open/close, otherwise they're useless in short-lived connection scenarios.
ErikEJ commentedon May 16, 2018
@divega Is someone having a hard look a SqlClient for these performance improvements, would likely hit a wider audience?
[-]Pool Connections[/-][+]Microsoft.Data.Sqlite: Pool Connections[/+]bricelam commentedon Nov 29, 2018
There are some PRAGMAs that change the functional behavior of the connection. If we add a pool, we'll need to consider how we handle these.
There are other statements that alter the connection state, but they're primarily for performance tuning and don't affect functionality.
bricelam commentedon Nov 29, 2018
Also, extensions (e.g. SpatiaLite) are enabled per-connection. I don't think they can be disabled aside from closing and re-opening the connection.
bricelam commentedon Nov 29, 2018
I decided this probably isn't a breaking change since we can make the behavioral breaking changes as part of #13826, and add pooling later to improve performance.
44 remaining items
sjb-sjb commentedon Mar 30, 2022
@ajcvickers: A simple question I'm sure but ... in the released version I am supposed to call SqliteConnection.ClearPool( SqliteConnection), where do I get the SqliteConnection from? DbContext.Database.GetDbConnection() returns a DbConnection instead.
Edit: the parameter type to InitializeDbConnection in SqliteRelationalConnection.cs would seem to suggest that the DbConnection can just be cast down to an SqliteConnection, is that correct? Would be nice to note this in the Breaking Changes document.
ajcvickers commentedon Mar 30, 2022
@sjb-sjb SqliteConnection inherits from DbConnetion. If you are using Sqlite, then your DbConnection is a SqliteConnection.
ajcvickers commentedon Mar 30, 2022
@sjb-sjb How is this a breaking change?
sjb-sjb commentedon Mar 30, 2022
The breaking change was that connection pooling results in the file being locked for longer than before. To unlock the file you need to call ClearPool. In my case when my UI program is in the background for a long time then I want to release the file so that OneDrive can copy it. The breaking change page talks about calling SqliteConnection.ClearPool but doesn't say how to get the SqliteConnection.
ajcvickers commentedon Mar 30, 2022
@sjb-sjb I'll bring it up with the team, but that seems like an extremely basic thing that anyone using C# should understand.
sjb-sjb commentedon Mar 30, 2022
Fair enough. I guess the reason I was confused was I assumed that SqliteConnection would be provided by the sqlite engine rather than by EF Core, so it wasn't a natural conclusion for me that it would be derived from an EF class.
ajcvickers commentedon Mar 30, 2022
DbConnection is not an EF class.
bricelam commentedon Mar 30, 2022
We did add a breaking change note about it here.
sjb-sjb commentedon Mar 30, 2022
I'm not trying to be hard-headed here. I know there is a breaking change note for EF, thanks, that's great. I'm just giving you the feedback that it would be nice if the breaking change note said "The SqliteConnection can be obtained by casting DbContext.Database.GetDbConnection() to SqliteConnection". It would save time poking around in the source code and bugging you nice folks in an attempt to figure it out. I know it's obvious to you but it wasn't very obvious to me for whatever reason.