Skip to content

Add ADO.NET Persistence support for SQLite#9846

Merged
ReubenBond merged 3 commits into
dotnet:mainfrom
jeromeksi:adonet/add_sql_lite
Feb 15, 2026
Merged

Add ADO.NET Persistence support for SQLite#9846
ReubenBond merged 3 commits into
dotnet:mainfrom
jeromeksi:adonet/add_sql_lite

Conversation

@jeromeksi

@jeromeksi jeromeksi commented Dec 17, 2025

Copy link
Copy Markdown
Contributor

Add ADO.NET Persistence support for SQLite

Description

This PR fixed the missing support for SQLite provider in Orleans.Persistence.AdoNet.

Context & Discovery

While reading the Microsoft.Orleans.Persistence.AdoNet documentation on Nugget.org , it is implied that various ADO.NET providers can be used. However, I discovered that attempting to use Microsoft.Data.Sqlite resulted in a KeyNotFoundException. Although the provider is theoretically supported by ADO.NET, the key was missing from the Orleans internal mapping, leading to a provider initialization failure. This PR addresses this gap.

Changes

1. Core Logic Updates

  • In DbConstantsStore.cs: Added entry in invariantNameToConsts dictionary for SQL Lite with the good enum value : AdoNetInvariants.InvariantNameSqlLite
  • Configuration: Defined specific DbConstants for SQLite:
    • Used double quotes (") as escape indicators.
    • Set supportsStreamNatively and isSynchronousAdoNetImplementation to false to align with Microsoft.Data.Sqlite behavior.
    • Configured the unionAllSelectTemplate for compatibility with state operations.

2. SQL Scripts

Added official scripts for the SQLite dialect following the project's standard structure of the other db provider :

  • SQLite-Main.sql: Table definitions for OrleansQuery.
  • SQLLite-Persistence.sql: Operational commands for Write, Read, and Clear operations.
    • Implemented Optimistic Concurrency Control (OCC) via the Version column.
    • Used changes() = 0 and INSERT ... SELECT WHERE NOT EXISTS logic to ensure compatibility across different SQLite versions.
    • Integrated mandatory aliases (NewGrainStateVersion, Version) required by the AdoNetGrainStorage internal mapping.

Note 1 : I have detect some error in the Orleans.Persistence.AdoNet/README.MD but i'm not sure if you like I change in this PR or an other
Note 2 : The dictionary invariantNameToConsts can be rewrite in more .NET 10 look, but same as Note 1 not sure if you prefere separate PR
Note 3 : I used an AI tool to help rephrase this description as my English is not perfect.

Microsoft Reviewers: Open in CodeFlow

@jeromeksi

Copy link
Copy Markdown
Contributor Author

@dotnet-policy-service agree

@jeromeksi jeromeksi marked this pull request as draft December 18, 2025 08:50
@jeromeksi jeromeksi marked this pull request as ready for review December 18, 2025 08:50
@jeromeksi

Copy link
Copy Markdown
Contributor Author

@ReubenBond, @benjaminpetit could you please review this PR? Or maybe I need to create an issue first ?

KSIGZKIEWIEZ Jérôme and others added 2 commits February 14, 2026 22:03
Resolve SQLite persistence query semantics, enable SQLite test dependencies, and add SQLite persistence fixture/regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Rename SQLLite scripts to Sqlite, update references/docs, and fix ClearStorage OCC signaling for stale ETags. Add a regression test to verify stale clear requests throw InconsistentStateException.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ReubenBond ReubenBond enabled auto-merge February 15, 2026 13:26
@ReubenBond ReubenBond added this pull request to the merge queue Feb 15, 2026
Merged via the queue into dotnet:main with commit aa9a257 Feb 15, 2026
56 of 59 checks passed
rkargMsft pushed a commit to rkargMsft/orleans that referenced this pull request Feb 27, 2026
* Add SQL Lite in invariantNameToConsts and SQL Script

* Fix SQLite ADO.NET persistence behavior and tests

Resolve SQLite persistence query semantics, enable SQLite test dependencies, and add SQLite persistence fixture/regression tests.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

* Fix Sqlite persistence gaps and naming

Rename SQLLite scripts to Sqlite, update references/docs, and fix ClearStorage OCC signaling for stale ETags. Add a regression test to verify stale clear requests throw InconsistentStateException.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

---------

Co-authored-by: KSIGZKIEWIEZ Jérôme <jerome.ksigzkiewiez@francebillet.com>
Co-authored-by: Reuben Bond <reuben.bond@gmail.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Mar 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants