Skip to content

Migrate from System.Data.SQLite to Microsoft.Data.Sqlite 8.0.0#2699

Merged
msevestre merged 14 commits intoOpen-Systems-Pharmacology:V13from
Felixmil:Microsoft.Data.Sqlite
Nov 10, 2025
Merged

Migrate from System.Data.SQLite to Microsoft.Data.Sqlite 8.0.0#2699
msevestre merged 14 commits intoOpen-Systems-Pharmacology:V13from
Felixmil:Microsoft.Data.Sqlite

Conversation

@Felixmil
Copy link

@Felixmil Felixmil commented Nov 4, 2025

Closes #2701

Sister PRs:

Summary

Migrated from System.Data.SQLite to Microsoft.Data.Sqlite 8.0.0 across the codebase.

Key Changes:

  • Replaced System.Data.SQLite package references with Microsoft.Data.Sqlite 8.0.0
  • Updated SessionFactoryProvider to use Microsoft.Data.Sqlite with NHibernate
  • Updated ConnectionProvider and SQLiteProjectCommandExecuter to use SqliteConnection
  • Updated test projects to reference Microsoft.Data.Sqlite

Type of change

Please mark relevant options with an x in the brackets.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires documentation changes (link at least one user or developer documentation issue):
  • Algorithm update - updates algorithm documentation/questions/answers etc.
  • Other (please describe): Dependency migration - replaced System.Data.SQLite with Microsoft.Data.Sqlite 8.0.0

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Provide instructions so we can reproduce. Please also list any relevant details for your test configuration

  • Integration tests
  • Unit tests
  • Manual tests
  • No tests required

Reviewer checklist

Mark everything that needs to be checked before merging the PR.

  • Check if the code is well documented
  • Check if the behavior is what is expected
  • Check if the code is well tested
  • Check if the code is readable and well formatted
  • Additional checks (document below if any)
  • Check if documentation update issue(s) are created if the option This change requires a documentation update above is selected

Screenshots (if appropriate):

Questions (if appropriate):

- Replace System.Data.SQLite package references with Microsoft.Data.Sqlite 8.0.0
- Update SessionFactoryProvider to use Microsoft.Data.Sqlite with NHibernate
- Update ConnectionProvider and SQLiteProjectCommandExecuter to use SqliteConnection
- Add SQLite native library configuration (PropertyGroups + PostBuild targets)
  to test and executable projects to ensure SQLite.Interop.dll is copied on Windows
- Update test projects to reference Microsoft.Data.Sqlite
…brary support

Microsoft.Data.Sqlite uses SQLitePCLRaw which provides e_sqlite3.dll  automatically via SQLitePCLRaw.bundle_e_sqlite3. The previous SQLite.Interop.dll from System.Data.SQLite is no longer needed.
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR migrates the SQLite database integration from System.Data.SQLite.Core to Microsoft.Data.Sqlite. The change modernizes the database provider and removes legacy build configurations.

  • Replaced System.Data.SQLite.Core package with Microsoft.Data.Sqlite and SQLitePCLRaw.bundle_e_sqlite3
  • Updated all SQLite connection instantiations from SQLiteConnection to SqliteConnection
  • Added new SessionFactoryProvider implementation for NHibernate configuration

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
OSPSuite.Starter.csproj Updated package references and removed PostBuild SQLite.Interop.dll copy target
OSPSuite.R.Performance.csproj Updated package references and removed PostBuild SQLite.Interop.dll copy target
OSPSuite.Infrastructure.Tests.csproj Updated package references and removed PostBuild SQLite.Interop.dll copy target
OSPSuite.Infrastructure.Serialization.csproj Replaced System.Data.SQLite.Core with Microsoft.Data.Sqlite
SessionFactoryProvider.cs New implementation for NHibernate session factory configuration with Microsoft.Data.Sqlite
SQLiteProjectCommandExecuter.cs Updated connection type from SQLiteConnection to SqliteConnection
IConnectionProvider.cs Simplified connection string and updated to SqliteConnection

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

{
var connectionString = $"Data Source={databasePath};Version=3;New=True;Compress=True;foreign keys=True";
var cn = new SQLiteConnection(connectionString);
var connectionString = $"Data Source={databasePath}";
Copy link

Copilot AI Nov 4, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The simplified connection string removes important SQLite configuration parameters that were present in the old implementation: 'Version=3;New=True;Compress=True;foreign keys=True'. Most critically, 'foreign keys=True' enforces referential integrity constraints. Consider adding back essential parameters, particularly foreign key enforcement using: var connectionString = $\"Data Source={databasePath};Foreign Keys=True\";

Suggested change
var connectionString = $"Data Source={databasePath}";
var connectionString = $"Data Source={databasePath};Foreign Keys=True";

Copilot uses AI. Check for mistakes.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Felixmil Not sure about Version and New arguments, but ForeignKeys and Compress must be set.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I don't see an option for compress, only the one for foreign keys.
https://learn.microsoft.com/en-us/dotnet/standard/data/sqlite/connection-strings

Regarding compress: needs to be investigated further (maybe it's always true, or can be set later via a property...)
We should create a separate issue for this.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created #2700

@rwmcintosh
Copy link
Member

Changing the target branch to V13 will impact how the assemblies are delivered from PKSim.R (and since V13 MoBi.R). Not in this PR, but in the downstream ones.

@Yuri05
Copy link
Member

Yuri05 commented Nov 4, 2025

Changing the target branch to V13 will impact how the assemblies are delivered from PKSim.R (and since V13 MoBi.R). Not in this PR, but in the downstream ones.

Then so be it.
This is a technology switch and I think it should not be done before V13 (will require additional testing etc.)

@rwmcintosh
Copy link
Member

Changing the target branch to V13 will impact how the assemblies are delivered from PKSim.R (and since V13 MoBi.R). Not in this PR, but in the downstream ones.

Then so be it. This is a technology switch and I think it should not be done before V13 (will require additional testing etc.)

Yes, I was going to make this comment that we should only consider it for V13, but also wanted to note for @Felixmil that it will require some rework before it's ready to merge all the way

…onnections

- Modified ConnectionProvider, SessionFactoryProvider, and SQLiteProjectCommandExecuter to append 'Foreign Keys=True' to the connection strings.
@Felixmil Felixmil requested a review from Yuri05 November 5, 2025 10:26
Copy link
Member

@msevestre msevestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SessionFactoryProvider

@rwmcintosh
why is this removeD? this is what Nhibernate used to connect to the DB

Or is this defined in each application

@msevestre
Copy link
Member

Added new SessionFactoryProvider implementation for NHibernate configuration

oh this was added with this PR lol. Ok maybe not used then

Copy link
Member

@msevestre msevestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is probabvly not required everywhere since we are not copying anyhting using GeneratePathProperty =true but I am not sure

@rwmcintosh
Copy link
Member

rwmcintosh commented Nov 7, 2025

Ok @Yuri05 @msevestre @Felixmil @benjaperez1983 if all the comments are satisfied, I suggest you get familiar with the changes in PK-Sim and MoBi PR's as well. Those won't build until we get a new core build, but it's a good idea to understand the whole scope of the changes in those as well.

All the tests pass on my local builds of PK-Sim and MoBi and I can open projects normally.

@Felixmil has an updated set of dll's that he will test with OSPSuite-R (that's the last app in the line to get these updates)

@rwmcintosh rwmcintosh marked this pull request as ready for review November 8, 2025 09:16
@Yuri05 Yuri05 requested a review from Copilot November 8, 2025 19:46
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

Copilot reviewed 8 out of 8 changed files in this pull request and generated no new comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@msevestre msevestre merged commit c8fbbd0 into Open-Systems-Pharmacology:V13 Nov 10, 2025
7 checks passed
@rwmcintosh rwmcintosh linked an issue Nov 10, 2025 that may be closed by this pull request
@rwmcintosh rwmcintosh added this to v13 Nov 10, 2025
@rwmcintosh rwmcintosh moved this to Done in v13 Nov 10, 2025
@Yuri05 Yuri05 moved this from Done to Verified in v13 Mar 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Verified

Development

Successfully merging this pull request may close these issues.

Migrate from System.Data.SQLite to Microsoft.Data.Sqlite

5 participants