-
Notifications
You must be signed in to change notification settings - Fork 8
Migrate from System.Data.SQLite to Microsoft.Data.Sqlite 8.0.0 #2699
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
msevestre
merged 14 commits into
Open-Systems-Pharmacology:V13
from
Felixmil:Microsoft.Data.Sqlite
Nov 10, 2025
Merged
Changes from 4 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
4bd3e67
Migrate from System.Data.SQLite to Microsoft.Data.Sqlite 8.0.0
Felixmil 640d903
Restore TargetDir/Folder
Felixmil 99bceef
Add SQLite native library configuration for Microsoft.Data.Sqlite 8.0.0
Felixmil 8986b95
Add SQLitePCLRaw.bundle_e_sqlite3 for Microsoft.Data.Sqlite native li…
Felixmil 627b35d
Merge remote-tracking branch 'upstream/V13' into Microsoft.Data.Sqlite
Felixmil 4458f84
Update connection strings to include 'Foreign Keys=True' for SQLite c…
Felixmil 3512952
Fix spelling: InitalizeSessionFactoryFor -> InitializeSessionFactoryFor
Felixmil 89c26ce
Remove leftovers
Felixmil 392671c
Remove unnecessary reference to SQLitePCLRaw.bundle_e_sqlite3
Felixmil 4f0d93a
Merge branch 'V13' into Microsoft.Data.Sqlite
rwmcintosh 5d39464
remove unused code
rwmcintosh 20cbd64
Remove comments on SQLite connection string compression
Felixmil f68c4e5
Remove 'Foreign Keys=True' from SQLite connection strings in SQLitePr…
Felixmil 815c115
Remove reference to Microsoft.Data.Sqlite from test project
Felixmil File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
src/OSPSuite.Infrastructure.Serialization/Services/SessionFactoryProvider.cs
rwmcintosh marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,55 @@ | ||
| using System; | ||
| using NHibernate; | ||
| using NHibernate.Cfg; | ||
| using NHibernate.Dialect; | ||
| using NHibernate.Driver; | ||
| using NHibernate.Tool.hbm2ddl; | ||
| using Microsoft.Data.Sqlite; | ||
|
|
||
Felixmil marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| namespace OSPSuite.Infrastructure.Serialization.Services | ||
| { | ||
| public class SessionFactoryProvider : ISessionFactoryProvider | ||
| { | ||
| public ISessionFactory InitalizeSessionFactoryFor(string dataSource) | ||
Felixmil marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| { | ||
| var configuration = CreateConfiguration(dataSource); | ||
| var sessionFactory = configuration.BuildSessionFactory(); | ||
| return sessionFactory; | ||
| } | ||
|
|
||
| public ISessionFactory OpenSessionFactoryFor(string dataSource) | ||
| { | ||
| var configuration = CreateConfiguration(dataSource); | ||
| var sessionFactory = configuration.BuildSessionFactory(); | ||
| return sessionFactory; | ||
| } | ||
|
|
||
| public SchemaExport GetSchemaExport(string dataSource) | ||
| { | ||
| var configuration = CreateConfiguration(dataSource); | ||
| return new SchemaExport(configuration); | ||
| } | ||
|
|
||
| private Configuration CreateConfiguration(string dataSource) | ||
| { | ||
| var configuration = new Configuration(); | ||
|
|
||
| // Configure database integration with Microsoft.Data.Sqlite | ||
| configuration.DataBaseIntegration(db => | ||
| { | ||
| // Use the SQLite driver that works with Microsoft.Data.Sqlite | ||
| db.Driver<NHibernate.Driver.SQLite20Driver>(); | ||
| db.Dialect<SQLiteDialect>(); | ||
| db.ConnectionString = $"Data Source={dataSource}"; | ||
| db.Timeout = 20; | ||
| }); | ||
|
|
||
| // Add mapping assemblies (you may need to adjust these based on your actual mapping assemblies) | ||
| configuration.AddAssembly(typeof(SessionFactoryProvider).Assembly); | ||
|
|
||
| return configuration; | ||
| } | ||
| } | ||
|
|
||
| } | ||
|
|
||
Felixmil marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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\";There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Felixmil Not sure about
VersionandNewarguments, butForeignKeysandCompressmust be set.There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Created #2700