From dff2e4a3285a05238976662307f8869acdfc307f Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Thu, 23 Oct 2025 11:55:28 +0200 Subject: [PATCH 01/12] Implement Microsoft.Data.Sqlite migration and update project references - Added a new Program.cs file for testing Microsoft.Data.Sqlite migration functionality. - Replaced System.Data.SQLite.Core with Microsoft.Data.Sqlite in multiple project files. - Updated connection handling in SessionFactoryProvider and ProjectFileCompressor to use Microsoft.Data.Sqlite. - Removed obsolete SQLite interop file handling from project files. --- TestSqliteMigration/Program.cs | 38 +++++++++++++++++++ src/MoBi.BatchTool/MoBi.BatchTool.csproj | 16 +------- .../ORM/SessionFactoryProvider.cs | 4 +- .../Services/ProjectFileCompressor.cs | 6 +-- src/MoBi/MoBi.csproj | 16 +------- tests/MoBi.Tests/MoBi.Tests.csproj | 16 +------- 6 files changed, 46 insertions(+), 50 deletions(-) create mode 100644 TestSqliteMigration/Program.cs diff --git a/TestSqliteMigration/Program.cs b/TestSqliteMigration/Program.cs new file mode 100644 index 000000000..a239c5dc2 --- /dev/null +++ b/TestSqliteMigration/Program.cs @@ -0,0 +1,38 @@ +using System; +using Microsoft.Data.Sqlite; + +namespace TestSqliteMigration +{ + class Program + { + static void Main(string[] args) + { + Console.WriteLine("Testing Microsoft.Data.Sqlite migration..."); + + // Test basic connection + using (var connection = new SqliteConnection("Data Source=:memory:")) + { + connection.Open(); + Console.WriteLine("✓ Connection opened successfully"); + + // Test basic query + using (var command = connection.CreateCommand()) + { + command.CommandText = "SELECT 1 as test_value"; + var result = command.ExecuteScalar(); + Console.WriteLine($"✓ Query executed successfully: {result}"); + } + + // Test VACUUM command (used in ProjectFileCompressor) + using (var command = connection.CreateCommand()) + { + command.CommandText = "VACUUM"; + command.ExecuteNonQuery(); + Console.WriteLine("✓ VACUUM command executed successfully"); + } + } + + Console.WriteLine("✓ All Microsoft.Data.Sqlite tests passed!"); + } + } +} \ No newline at end of file diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index a17bb9a06..7fcdf6e2c 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -58,7 +58,7 @@ - + @@ -67,18 +67,4 @@ - - - true - false - false - false - - - - - - - - \ No newline at end of file diff --git a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs index f3cd5f9ae..61ac230ca 100644 --- a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs +++ b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs @@ -38,11 +38,11 @@ private Configuration createSqlLiteConfigurationFor(string dataSource) var configuration = new Configuration(); var path = dataSource.ToUNCPath(); configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); - configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SQLite20Driver"); + configuration.SetProperty("connection.driver_class", "NHibernate.Driver.MicrosoftDataSqliteDriver"); configuration.SetProperty("dialect", "NHibernate.Dialect.SQLiteDialect"); configuration.SetProperty("query.substitutions", "true=1;false=0"); configuration.SetProperty("show_sql", "false"); - configuration.SetProperty("connection.connection_string", $"Data Source={path};Version=3;New=False;Compress=True;"); + configuration.SetProperty("connection.connection_string", $"Data Source={path}"); return Fluently.Configure(configuration) .Mappings(cfg => cfg.FluentMappings.AddFromAssemblyOf()).BuildConfiguration(); diff --git a/src/MoBi.Core/Services/ProjectFileCompressor.cs b/src/MoBi.Core/Services/ProjectFileCompressor.cs index f7142a8da..7cf0bf2d8 100644 --- a/src/MoBi.Core/Services/ProjectFileCompressor.cs +++ b/src/MoBi.Core/Services/ProjectFileCompressor.cs @@ -1,5 +1,5 @@ using System.Data.Common; -using System.Data.SQLite; +using Microsoft.Data.Sqlite; using OSPSuite.Core.Extensions; namespace MoBi.Core.Services @@ -14,14 +14,14 @@ public class ProjectFileCompressor : IProjectFileCompressor public void Compress(string projectFile) { var path = projectFile.ToUNCPath(); - using (var sqlLite = new SQLiteConnection(string.Format("Data Source={0}", path))) + using (var sqlLite = new SqliteConnection(string.Format("Data Source={0}", path))) { sqlLite.Open(); vacuum(sqlLite); } } - private void vacuum(SQLiteConnection sqlLite) + private void vacuum(SqliteConnection sqlLite) { ExecuteNonQuery(sqlLite, "vacuum;"); } diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index ad356b4b3..e7ae6d267 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -70,7 +70,7 @@ - + @@ -86,18 +86,4 @@ - - - true - false - false - false - - - - - - - - \ No newline at end of file diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index c1d1f622a..7830ab468 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -50,7 +50,7 @@ - + @@ -105,18 +105,4 @@ - - - true - false - false - false - - - - - - - - \ No newline at end of file From fdd2ff0a00a57a36effb107a9a824fd0a3cc493f Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Thu, 23 Oct 2025 14:09:05 +0200 Subject: [PATCH 02/12] Fix NHibernate driver configuration for Microsoft.Data.Sqlite - Replace custom MicrosoftDataSqliteDriver with SQLite20Driver - SQLite20Driver is compatible with Microsoft.Data.Sqlite connection strings - Removes custom driver implementation that was causing build errors - Maintains NHibernate functionality while supporting Microsoft.Data.Sqlite - Resolves CI build error: MicrosoftDataSqliteDriver not found --- src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs index 61ac230ca..0e634d9b7 100644 --- a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs +++ b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs @@ -38,7 +38,7 @@ private Configuration createSqlLiteConfigurationFor(string dataSource) var configuration = new Configuration(); var path = dataSource.ToUNCPath(); configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); - configuration.SetProperty("connection.driver_class", "NHibernate.Driver.MicrosoftDataSqliteDriver"); + configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SQLite20Driver"); configuration.SetProperty("dialect", "NHibernate.Dialect.SQLiteDialect"); configuration.SetProperty("query.substitutions", "true=1;false=0"); configuration.SetProperty("show_sql", "false"); From 4456e7d088791177d79ea70646c1282d5509e789 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Thu, 23 Oct 2025 14:13:22 +0200 Subject: [PATCH 03/12] Add missing Microsoft.Data.Sqlite package reference to MoBi.Core - ProjectFileCompressor requires Microsoft.Data.Sqlite package - Fixes build error: CS0234 and CS0246 for SqliteConnection - Restores the package reference that was lost during git history cleanup --- src/MoBi.Core/MoBi.Core.csproj | 1 + 1 file changed, 1 insertion(+) diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index d8f6ea9e6..3cd488ec6 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -40,6 +40,7 @@ + From 9682725549ce3890591bd357c2ffc306656237b8 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Thu, 23 Oct 2025 14:20:34 +0200 Subject: [PATCH 04/12] Remove Microsoft.Data.Sqlite migration tests --- TestSqliteMigration/Program.cs | 38 ---------------------------------- 1 file changed, 38 deletions(-) delete mode 100644 TestSqliteMigration/Program.cs diff --git a/TestSqliteMigration/Program.cs b/TestSqliteMigration/Program.cs deleted file mode 100644 index a239c5dc2..000000000 --- a/TestSqliteMigration/Program.cs +++ /dev/null @@ -1,38 +0,0 @@ -using System; -using Microsoft.Data.Sqlite; - -namespace TestSqliteMigration -{ - class Program - { - static void Main(string[] args) - { - Console.WriteLine("Testing Microsoft.Data.Sqlite migration..."); - - // Test basic connection - using (var connection = new SqliteConnection("Data Source=:memory:")) - { - connection.Open(); - Console.WriteLine("✓ Connection opened successfully"); - - // Test basic query - using (var command = connection.CreateCommand()) - { - command.CommandText = "SELECT 1 as test_value"; - var result = command.ExecuteScalar(); - Console.WriteLine($"✓ Query executed successfully: {result}"); - } - - // Test VACUUM command (used in ProjectFileCompressor) - using (var command = connection.CreateCommand()) - { - command.CommandText = "VACUUM"; - command.ExecuteNonQuery(); - Console.WriteLine("✓ VACUUM command executed successfully"); - } - } - - Console.WriteLine("✓ All Microsoft.Data.Sqlite tests passed!"); - } - } -} \ No newline at end of file From e790ce66ce9049ec08c485d55bd21d42bb977662 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Tue, 4 Nov 2025 10:57:37 +0100 Subject: [PATCH 05/12] Migrate from System.Data.SQLite to Microsoft.Data.Sqlite - Replace System.Data.SQLite.Core with Microsoft.Data.Sqlite in all projects - Update ProjectFileCompressor and NHibernate configuration for Microsoft.Data.Sqlite - Remove SQLite interop file handling (Microsoft.Data.Sqlite handles this automatically) Resolves macOS ARM64 P/Invoke stack overflow errors and provides cross-platform compatibility. --- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 16 +--------------- src/MoBi.Core/MoBi.Core.csproj | 1 + .../Serialization/ORM/SessionFactoryProvider.cs | 2 +- src/MoBi.Core/Services/ProjectFileCompressor.cs | 6 +++--- src/MoBi/MoBi.csproj | 16 +--------------- tests/MoBi.Tests/MoBi.Tests.csproj | 16 +--------------- 6 files changed, 8 insertions(+), 49 deletions(-) diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index a17bb9a06..7fcdf6e2c 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -58,7 +58,7 @@ - + @@ -67,18 +67,4 @@ - - - true - false - false - false - - - - - - - - \ No newline at end of file diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index d8f6ea9e6..3cd488ec6 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -40,6 +40,7 @@ + diff --git a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs index f3cd5f9ae..0e634d9b7 100644 --- a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs +++ b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs @@ -42,7 +42,7 @@ private Configuration createSqlLiteConfigurationFor(string dataSource) configuration.SetProperty("dialect", "NHibernate.Dialect.SQLiteDialect"); configuration.SetProperty("query.substitutions", "true=1;false=0"); configuration.SetProperty("show_sql", "false"); - configuration.SetProperty("connection.connection_string", $"Data Source={path};Version=3;New=False;Compress=True;"); + configuration.SetProperty("connection.connection_string", $"Data Source={path}"); return Fluently.Configure(configuration) .Mappings(cfg => cfg.FluentMappings.AddFromAssemblyOf()).BuildConfiguration(); diff --git a/src/MoBi.Core/Services/ProjectFileCompressor.cs b/src/MoBi.Core/Services/ProjectFileCompressor.cs index f7142a8da..7cf0bf2d8 100644 --- a/src/MoBi.Core/Services/ProjectFileCompressor.cs +++ b/src/MoBi.Core/Services/ProjectFileCompressor.cs @@ -1,5 +1,5 @@ using System.Data.Common; -using System.Data.SQLite; +using Microsoft.Data.Sqlite; using OSPSuite.Core.Extensions; namespace MoBi.Core.Services @@ -14,14 +14,14 @@ public class ProjectFileCompressor : IProjectFileCompressor public void Compress(string projectFile) { var path = projectFile.ToUNCPath(); - using (var sqlLite = new SQLiteConnection(string.Format("Data Source={0}", path))) + using (var sqlLite = new SqliteConnection(string.Format("Data Source={0}", path))) { sqlLite.Open(); vacuum(sqlLite); } } - private void vacuum(SQLiteConnection sqlLite) + private void vacuum(SqliteConnection sqlLite) { ExecuteNonQuery(sqlLite, "vacuum;"); } diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index ad356b4b3..e7ae6d267 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -70,7 +70,7 @@ - + @@ -86,18 +86,4 @@ - - - true - false - false - false - - - - - - - - \ No newline at end of file diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index c1d1f622a..7830ab468 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -50,7 +50,7 @@ - + @@ -105,18 +105,4 @@ - - - true - false - false - false - - - - - - - - \ No newline at end of file From 5258e5d368f8add64995a1f72afd9f5260a7604a Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Wed, 5 Nov 2025 09:53:16 +0100 Subject: [PATCH 06/12] Update ProjectFileCompressor to use string interpolation for connection string --- src/MoBi.Core/Services/ProjectFileCompressor.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/MoBi.Core/Services/ProjectFileCompressor.cs b/src/MoBi.Core/Services/ProjectFileCompressor.cs index 7cf0bf2d8..941064abc 100644 --- a/src/MoBi.Core/Services/ProjectFileCompressor.cs +++ b/src/MoBi.Core/Services/ProjectFileCompressor.cs @@ -14,7 +14,7 @@ public class ProjectFileCompressor : IProjectFileCompressor public void Compress(string projectFile) { var path = projectFile.ToUNCPath(); - using (var sqlLite = new SqliteConnection(string.Format("Data Source={0}", path))) + using (var sqlLite = new SqliteConnection($"Data Source={path}")) { sqlLite.Open(); vacuum(sqlLite); From 7abf6dbb0e2a40cc1ce9a1fed291e37ed448c3a5 Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Wed, 5 Nov 2025 10:25:08 +0100 Subject: [PATCH 07/12] Fix file locking issues in tests after Microsoft.Data.Sqlite migration Clear connection pools when closing projects to release file handles. Fix test cleanup to properly close projects loaded by batch runner. Microsoft.Data.Sqlite enables connection pooling by default (unlike System.Data.SQLite), which keeps database files locked even after closing connections. --- .../Serialization/ORM/ContextPersistor.cs | 4 ++++ .../IntegrationTests/SnapshotRunnerSpecs.cs | 22 ++++++++++++++++--- 2 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs b/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs index df1a83cb7..92539632a 100644 --- a/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs +++ b/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs @@ -2,6 +2,7 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; +using Microsoft.Data.Sqlite; using MoBi.Assets; using MoBi.Core.Commands; using MoBi.Core.Domain.Builder; @@ -88,6 +89,7 @@ public void Load(IMoBiContext context, string projectFullPath) // Exception occurs while opening the project! // close the file and rethrow the exception _sessionManager.CloseFactory(); + SqliteConnection.ClearAllPools(); context.Clear(); throw; } @@ -133,6 +135,7 @@ private void verifyFileNotReadOnly(string projectFilePath) public MoBiProject NewProject(IMoBiContext context) { _sessionManager.CloseFactory(); + SqliteConnection.ClearAllPools(); context.NewProject(); var project = context.CurrentProject; project.SimulationSettings = _simulationSettingsFactory.CreateDefault(); @@ -142,6 +145,7 @@ public MoBiProject NewProject(IMoBiContext context) public void CloseProject(IMoBiContext context) { _sessionManager.CloseFactory(); + SqliteConnection.ClearAllPools(); context.Clear(); } diff --git a/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs b/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs index f689f5d7d..b6c5e0e7b 100644 --- a/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs +++ b/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs @@ -23,6 +23,8 @@ public class when_exporting_a_snapshot_from_project : concern_for_SnapshotRunner private readonly string _projectFileName = "snapshot_no_pksim_modules.mbp3"; private string _jsonPath; private string _projectPath; + private IContextPersistor _contextPersistor; + private IMoBiContext _context; protected override void Context() { @@ -68,9 +70,9 @@ private void createProjectFromSnapshot() private void loadProject(string projectFile) { - var contextPersistor = IoC.Resolve(); - var context = IoC.Resolve(); - contextPersistor.Load(context, projectFile); + _contextPersistor = IoC.Resolve(); + _context = IoC.Resolve(); + _contextPersistor.Load(_context, projectFile); } protected override void Because() @@ -86,6 +88,10 @@ public void the_project_file_should_be_created() public override void Cleanup() { + // Close the project to release file handles before attempting to delete directories + if (_context != null) + _contextPersistor?.CloseProject(_context); + base.Cleanup(); if (Directory.Exists(_projectDirectory)) Directory.Delete(_projectDirectory, true); @@ -143,6 +149,16 @@ public void the_project_file_should_be_created() public override void Cleanup() { + // Close the project to release file handles before attempting to delete directories + // The batch runner loads the project into the shared singleton context and should close it, + // but ensure it's closed and connection pools are cleared in case of timing issues + var context = IoC.Resolve(); + if (context?.CurrentProject != null) + { + var contextPersistor = IoC.Resolve(); + contextPersistor?.CloseProject(context); + } + base.Cleanup(); if (Directory.Exists(_projectDirectory)) Directory.Delete(_projectDirectory, true); From 66e04617125fdba2457c72adad2d16b74780a0ae Mon Sep 17 00:00:00 2001 From: Felix MIL Date: Wed, 5 Nov 2025 17:41:49 +0100 Subject: [PATCH 08/12] Remove unnecessary references + remove unrelated changes --- src/MoBi.Core/MoBi.Core.csproj | 1 - src/MoBi/MoBi.csproj | 4 ---- 2 files changed, 5 deletions(-) diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index f20171ad7..768403cb5 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -37,7 +37,6 @@ - diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 14c7338a3..a6b0e323a 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -83,8 +83,4 @@ - - - - \ No newline at end of file From faa398029485ebfd91f6fbe8b29a5a954601a079 Mon Sep 17 00:00:00 2001 From: Robert McIntosh <261477+rwmcintosh@users.noreply.github.com> Date: Fri, 7 Nov 2025 05:08:48 -0500 Subject: [PATCH 09/12] Use only Microsoft.Data.SQLite --- docs/project_schema.sql | 93 +++++++++++++++++++ src/MoBi.Assets/MoBi.Assets.csproj | 6 +- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.CLI.Core/MoBi.CLI.Core.csproj | 14 +-- src/MoBi.CLI/MoBi.CLI.csproj | 11 +-- src/MoBi.Core/MoBi.Core.csproj | 15 +-- .../ORM/SessionFactoryProvider.cs | 13 +-- src/MoBi.Engine/MoBi.Engine.csproj | 4 +- .../MoBi.Presentation.csproj | 6 +- src/MoBi.R/MoBi.R.csproj | 8 +- src/MoBi.UI/MoBi.UI.csproj | 10 +- src/MoBi/MoBi.csproj | 4 +- .../DomainHelperForSpecs.cs | 4 + .../MoBi.HelpersForTests.csproj | 2 +- .../SessionFactoryProviderHelperForSpecs.cs | 4 +- .../Core/SessionFactoryProviderSpecs.cs | 24 ++++- tests/MoBi.Tests/MoBi.Tests.csproj | 6 +- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 +- 18 files changed, 171 insertions(+), 59 deletions(-) create mode 100644 docs/project_schema.sql diff --git a/docs/project_schema.sql b/docs/project_schema.sql new file mode 100644 index 000000000..b003b9361 --- /dev/null +++ b/docs/project_schema.sql @@ -0,0 +1,93 @@ + + PRAGMA foreign_keys = OFF + + drop table if exists COMMANDS + + drop table if exists COMMAND_PROPERTIES + + drop table if exists DATA_REPOSITORIES + + drop table if exists ENTITIES + + drop table if exists SIMULATIONS + + drop table if exists HISTORY_ITEMS + + drop table if exists CONTENTS + + drop table if exists PROJECTS + + PRAGMA foreign_keys = ON + + create table COMMANDS ( + Id TEXT not null, + CommandId TEXT not null, + Discriminator TEXT not null, + CommandInverseId TEXT, + CommandType TEXT, + ObjectType TEXT, + Description TEXT, + ExtendedDescription TEXT, + Visible INTEGER, + Comment TEXT, + Sequence INTEGER, + ParentId TEXT, + primary key (Id), + constraint FK_DD4B87FE foreign key (ParentId) references COMMANDS + ) + + create table COMMAND_PROPERTIES ( + Id integer primary key autoincrement, + Name TEXT, + Value TEXT, + CommandId TEXT, + constraint FK_71C9276E foreign key (CommandId) references COMMANDS + ) + + create table DATA_REPOSITORIES ( + Id TEXT not null, + ContentId INTEGER, + SimulationId TEXT, + primary key (Id), + constraint fk_DataRepository_Content foreign key (ContentId) references CONTENTS, + constraint FK_524447BC foreign key (SimulationId) references SIMULATIONS + ) + + create table ENTITIES ( + Id TEXT not null, + Discriminator TEXT not null, + ContentId INTEGER, + ProjectId INTEGER, + primary key (Id), + constraint fk_Entity_Content foreign key (ContentId) references CONTENTS, + constraint FK_9F0A793C foreign key (ProjectId) references PROJECTS + ) + + create table SIMULATIONS ( + SimulationId TEXT not null, + primary key (SimulationId), + constraint FK_A2608560 foreign key (SimulationId) references ENTITIES + ) + + create table HISTORY_ITEMS ( + Id TEXT not null, + UserId TEXT, + DateTime TEXT, + State INTEGER, + Sequence INTEGER, + CommandId TEXT, + primary key (Id), + constraint fk_HistoryItem_Command foreign key (CommandId) references COMMANDS + ) + + create table CONTENTS ( + Id integer primary key autoincrement, + Data image + ) + + create table PROJECTS ( + Id integer primary key autoincrement, + Version INTEGER, + ContentId INTEGER, + constraint fk_Project_Content foreign key (ContentId) references CONTENTS + ) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 2dd50ea0d..ae8166a90 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -22,9 +22,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 5fcdf7783..2c0bf8030 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj b/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj index a0b225027..b63b5b42b 100644 --- a/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj +++ b/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj @@ -16,14 +16,14 @@ - - + + - - - - - + + + + + diff --git a/src/MoBi.CLI/MoBi.CLI.csproj b/src/MoBi.CLI/MoBi.CLI.csproj index 9984bc215..5bc82436b 100644 --- a/src/MoBi.CLI/MoBi.CLI.csproj +++ b/src/MoBi.CLI/MoBi.CLI.csproj @@ -23,17 +23,16 @@ - - - + + + - - - + + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 768403cb5..794a92171 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -28,15 +28,16 @@ + - - - - - - - + + + + + + + diff --git a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs index 0e634d9b7..bf60f7a7e 100644 --- a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs +++ b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs @@ -9,7 +9,7 @@ namespace MoBi.Core.Serialization.ORM { public class SessionFactoryProvider : ISessionFactoryProvider { - public ISessionFactory InitalizeSessionFactoryFor(string dataSource) + public ISessionFactory InitializeSessionFactoryFor(string dataSource) { var cfg = createSqlLiteConfigurationFor(dataSource); //Create schema for database @@ -20,10 +20,7 @@ public ISessionFactory InitalizeSessionFactoryFor(string dataSource) public ISessionFactory OpenSessionFactoryFor(string dataSource) { - var cfg = createSqlLiteConfigurationFor(dataSource); - var update = new SchemaUpdate(cfg); - update.Execute(useStdOut: false, doUpdate: true); - return cfg.BuildSessionFactory(); + return createSqlLiteConfigurationFor(dataSource).BuildSessionFactory(); } public SchemaExport GetSchemaExport(string dataSource) @@ -38,11 +35,11 @@ private Configuration createSqlLiteConfigurationFor(string dataSource) var configuration = new Configuration(); var path = dataSource.ToUNCPath(); configuration.SetProperty("connection.provider", "NHibernate.Connection.DriverConnectionProvider"); - configuration.SetProperty("connection.driver_class", "NHibernate.Driver.SQLite20Driver"); - configuration.SetProperty("dialect", "NHibernate.Dialect.SQLiteDialect"); + configuration.SetProperty("connection.driver_class", typeof(NHibernate.Extensions.Sqlite.SqliteDriver).AssemblyQualifiedName); + configuration.SetProperty("dialect", typeof(NHibernate.Extensions.Sqlite.SqliteDialect).AssemblyQualifiedName); configuration.SetProperty("query.substitutions", "true=1;false=0"); configuration.SetProperty("show_sql", "false"); - configuration.SetProperty("connection.connection_string", $"Data Source={path}"); + configuration.SetProperty("connection.connection_string", $"Data Source={path};Cache=Shared"); return Fluently.Configure(configuration) .Mappings(cfg => cfg.FluentMappings.AddFromAssemblyOf()).BuildConfiguration(); diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 431419586..3623ab391 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -28,8 +28,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index ff6fd9547..411b7bed6 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -23,9 +23,9 @@ - - - + + + diff --git a/src/MoBi.R/MoBi.R.csproj b/src/MoBi.R/MoBi.R.csproj index d061191c1..291b22988 100644 --- a/src/MoBi.R/MoBi.R.csproj +++ b/src/MoBi.R/MoBi.R.csproj @@ -6,10 +6,10 @@ - - - - + + + + diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index 8d7c35bd3..a47cba443 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,11 +26,11 @@ - - - - - + + + + + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index a6b0e323a..9ba813721 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -67,13 +67,13 @@ - + - + diff --git a/tests/MoBi.HelpersForTests/DomainHelperForSpecs.cs b/tests/MoBi.HelpersForTests/DomainHelperForSpecs.cs index 45ad95e8d..2cbbfd85e 100644 --- a/tests/MoBi.HelpersForTests/DomainHelperForSpecs.cs +++ b/tests/MoBi.HelpersForTests/DomainHelperForSpecs.cs @@ -17,6 +17,10 @@ public static class DomainHelperForSpecs private static Dimension _concentrationDimension; private static Dimension _timeDimension; + private static readonly string PATH_TO_DOCS = "..\\..\\..\\..\\..\\docs\\"; + + public static string ProjectSchemaDumpFilePath => Path.Combine(AppDomain.CurrentDomain.BaseDirectory, PATH_TO_DOCS, "project_schema.sql"); + public static string TestFileFullPath(string fileName) { return Path.Combine(TestFileDirectory, fileName); diff --git a/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj b/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj index 70efac741..20c75c303 100644 --- a/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj +++ b/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/MoBi.Tests/Core/SessionFactoryProviderHelperForSpecs.cs b/tests/MoBi.Tests/Core/SessionFactoryProviderHelperForSpecs.cs index bba54dded..032b4eb60 100644 --- a/tests/MoBi.Tests/Core/SessionFactoryProviderHelperForSpecs.cs +++ b/tests/MoBi.Tests/Core/SessionFactoryProviderHelperForSpecs.cs @@ -7,7 +7,7 @@ namespace MoBi.Core { public abstract class ContextSpecificationWithSerializationDatabase : ContextSpecification { - private SessionFactoryProvider _sessionFactoryProvider; + protected SessionFactoryProvider _sessionFactoryProvider; protected ISessionFactory _sessionFactory; protected string _dataBaseFile; @@ -17,7 +17,7 @@ public override void GlobalContext() _sessionFactoryProvider = new SessionFactoryProvider(); _dataBaseFile = FileHelper.GenerateTemporaryFileName(); - _sessionFactory = _sessionFactoryProvider.InitalizeSessionFactoryFor(_dataBaseFile); + _sessionFactory = _sessionFactoryProvider.InitializeSessionFactoryFor(_dataBaseFile); } public override void GlobalCleanup() diff --git a/tests/MoBi.Tests/Core/SessionFactoryProviderSpecs.cs b/tests/MoBi.Tests/Core/SessionFactoryProviderSpecs.cs index 772d94a53..09f62fe5c 100644 --- a/tests/MoBi.Tests/Core/SessionFactoryProviderSpecs.cs +++ b/tests/MoBi.Tests/Core/SessionFactoryProviderSpecs.cs @@ -1,10 +1,12 @@ -using OSPSuite.BDDHelper; +using MoBi.Core.Serialization.ORM; using MoBi.Core.Serialization.ORM.MetaData; +using MoBi.HelpersForTests; +using OSPSuite.BDDHelper; using OSPSuite.Infrastructure.Serialization.Services; +using System.IO; namespace MoBi.Core { - public class When_creating_a_session_factory_for_an_existing_given_data_source : ContextSpecificationWithSerializationDatabase { [Observation] @@ -28,4 +30,20 @@ public void should_be_able_to_open_a_session() } } -} \ No newline at end of file + // Dumps the schema of the project database. This makes changes in the schema trackable through version control + public class Comparing_schema_files_for_tracking_purpose : ContextSpecificationWithSerializationDatabase + { + [Observation] + public void should_create_the_database_schema() + { + + var schemaExport = _sessionFactoryProvider.GetSchemaExport(_dataBaseFile); + var directoryName = Path.GetDirectoryName(DomainHelperForSpecs.ProjectSchemaDumpFilePath); + if (!Directory.Exists(directoryName)) + Directory.CreateDirectory(directoryName); + + schemaExport.SetOutputFile(DomainHelperForSpecs.ProjectSchemaDumpFilePath); + schemaExport.Create(true, true); + } + } +} \ No newline at end of file diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index fbdde6d56..a027bd1c4 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -38,9 +38,9 @@ - - - + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index ae7b427a0..ad32e4780 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -19,8 +19,8 @@ - - + + From 452cbdd5bdab981e090b4a31b171945516d7a9e8 Mon Sep 17 00:00:00 2001 From: Robert McIntosh <261477+rwmcintosh@users.noreply.github.com> Date: Sun, 9 Nov 2025 21:02:35 -0500 Subject: [PATCH 10/12] update core --- src/MoBi.Assets/MoBi.Assets.csproj | 6 +++--- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.CLI.Core/MoBi.CLI.Core.csproj | 14 +++++++------- src/MoBi.CLI/MoBi.CLI.csproj | 10 +++++----- src/MoBi.Core/MoBi.Core.csproj | 14 +++++++------- src/MoBi.Engine/MoBi.Engine.csproj | 4 ++-- src/MoBi.Presentation/MoBi.Presentation.csproj | 6 +++--- src/MoBi.R/MoBi.R.csproj | 8 ++++---- src/MoBi.UI/MoBi.UI.csproj | 10 +++++----- src/MoBi/MoBi.csproj | 4 ++-- .../MoBi.HelpersForTests.csproj | 2 +- tests/MoBi.Tests/MoBi.Tests.csproj | 6 +++--- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 ++-- 13 files changed, 45 insertions(+), 45 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index ae8166a90..7b300ad7a 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -22,9 +22,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index 2c0bf8030..e7be3c774 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj b/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj index b63b5b42b..480ba5a5a 100644 --- a/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj +++ b/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj @@ -16,14 +16,14 @@ - - + + - - - - - + + + + + diff --git a/src/MoBi.CLI/MoBi.CLI.csproj b/src/MoBi.CLI/MoBi.CLI.csproj index 5bc82436b..40cf7ad24 100644 --- a/src/MoBi.CLI/MoBi.CLI.csproj +++ b/src/MoBi.CLI/MoBi.CLI.csproj @@ -23,16 +23,16 @@ - - - + + + - - + + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 794a92171..4718c3e02 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 3623ab391..8c2d62c9d 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -28,8 +28,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index 411b7bed6..bf28c8e80 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -23,9 +23,9 @@ - - - + + + diff --git a/src/MoBi.R/MoBi.R.csproj b/src/MoBi.R/MoBi.R.csproj index 291b22988..12cb3673e 100644 --- a/src/MoBi.R/MoBi.R.csproj +++ b/src/MoBi.R/MoBi.R.csproj @@ -6,10 +6,10 @@ - - - - + + + + diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index a47cba443..01ca81c2d 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,11 +26,11 @@ - - - - - + + + + + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index 9ba813721..da7a4883e 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -67,13 +67,13 @@ - + - + diff --git a/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj b/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj index 20c75c303..42bac6814 100644 --- a/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj +++ b/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index a027bd1c4..db86df7f5 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -38,9 +38,9 @@ - - - + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index ad32e4780..44fb362b5 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -19,8 +19,8 @@ - - + + From a6016714699e879c9dba10583ed902e838c637a6 Mon Sep 17 00:00:00 2001 From: Robert McIntosh <261477+rwmcintosh@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:20:02 -0500 Subject: [PATCH 11/12] update core --- src/MoBi.Assets/MoBi.Assets.csproj | 6 +++--- src/MoBi.BatchTool/MoBi.BatchTool.csproj | 2 +- src/MoBi.CLI.Core/MoBi.CLI.Core.csproj | 14 +++++++------- src/MoBi.CLI/MoBi.CLI.csproj | 10 +++++----- src/MoBi.Core/MoBi.Core.csproj | 14 +++++++------- .../Serialization/ORM/ContextPersistor.cs | 4 ---- .../Serialization/ORM/SessionFactoryProvider.cs | 3 ++- src/MoBi.Core/Services/ProjectFileCompressor.cs | 7 ++++--- src/MoBi.Engine/MoBi.Engine.csproj | 4 ++-- src/MoBi.Presentation/MoBi.Presentation.csproj | 6 +++--- src/MoBi.R/MoBi.R.csproj | 8 ++++---- src/MoBi.UI/MoBi.UI.csproj | 10 +++++----- src/MoBi/MoBi.csproj | 4 ++-- .../MoBi.HelpersForTests.csproj | 2 +- tests/MoBi.Tests/MoBi.Tests.csproj | 6 +++--- tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj | 4 ++-- 16 files changed, 51 insertions(+), 53 deletions(-) diff --git a/src/MoBi.Assets/MoBi.Assets.csproj b/src/MoBi.Assets/MoBi.Assets.csproj index 7b300ad7a..314f70ce1 100644 --- a/src/MoBi.Assets/MoBi.Assets.csproj +++ b/src/MoBi.Assets/MoBi.Assets.csproj @@ -22,9 +22,9 @@ - - - + + + diff --git a/src/MoBi.BatchTool/MoBi.BatchTool.csproj b/src/MoBi.BatchTool/MoBi.BatchTool.csproj index e7be3c774..90e5c9237 100644 --- a/src/MoBi.BatchTool/MoBi.BatchTool.csproj +++ b/src/MoBi.BatchTool/MoBi.BatchTool.csproj @@ -49,7 +49,7 @@ - + diff --git a/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj b/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj index 480ba5a5a..6a3ef925f 100644 --- a/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj +++ b/src/MoBi.CLI.Core/MoBi.CLI.Core.csproj @@ -16,14 +16,14 @@ - - + + - - - - - + + + + + diff --git a/src/MoBi.CLI/MoBi.CLI.csproj b/src/MoBi.CLI/MoBi.CLI.csproj index 40cf7ad24..199d95c75 100644 --- a/src/MoBi.CLI/MoBi.CLI.csproj +++ b/src/MoBi.CLI/MoBi.CLI.csproj @@ -23,16 +23,16 @@ - - - + + + - - + + diff --git a/src/MoBi.Core/MoBi.Core.csproj b/src/MoBi.Core/MoBi.Core.csproj index 4718c3e02..c0dd7525d 100644 --- a/src/MoBi.Core/MoBi.Core.csproj +++ b/src/MoBi.Core/MoBi.Core.csproj @@ -31,13 +31,13 @@ - - - - - - - + + + + + + + diff --git a/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs b/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs index 92539632a..df1a83cb7 100644 --- a/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs +++ b/src/MoBi.Core/Serialization/ORM/ContextPersistor.cs @@ -2,7 +2,6 @@ using System.Collections.ObjectModel; using System.IO; using System.Linq; -using Microsoft.Data.Sqlite; using MoBi.Assets; using MoBi.Core.Commands; using MoBi.Core.Domain.Builder; @@ -89,7 +88,6 @@ public void Load(IMoBiContext context, string projectFullPath) // Exception occurs while opening the project! // close the file and rethrow the exception _sessionManager.CloseFactory(); - SqliteConnection.ClearAllPools(); context.Clear(); throw; } @@ -135,7 +133,6 @@ private void verifyFileNotReadOnly(string projectFilePath) public MoBiProject NewProject(IMoBiContext context) { _sessionManager.CloseFactory(); - SqliteConnection.ClearAllPools(); context.NewProject(); var project = context.CurrentProject; project.SimulationSettings = _simulationSettingsFactory.CreateDefault(); @@ -145,7 +142,6 @@ public MoBiProject NewProject(IMoBiContext context) public void CloseProject(IMoBiContext context) { _sessionManager.CloseFactory(); - SqliteConnection.ClearAllPools(); context.Clear(); } diff --git a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs index bf60f7a7e..ad402b020 100644 --- a/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs +++ b/src/MoBi.Core/Serialization/ORM/SessionFactoryProvider.cs @@ -3,6 +3,7 @@ using NHibernate.Cfg; using NHibernate.Tool.hbm2ddl; using OSPSuite.Core.Extensions; +using OSPSuite.Infrastructure.Serialization.Extensions; using OSPSuite.Infrastructure.Serialization.Services; namespace MoBi.Core.Serialization.ORM @@ -39,7 +40,7 @@ private Configuration createSqlLiteConfigurationFor(string dataSource) configuration.SetProperty("dialect", typeof(NHibernate.Extensions.Sqlite.SqliteDialect).AssemblyQualifiedName); configuration.SetProperty("query.substitutions", "true=1;false=0"); configuration.SetProperty("show_sql", "false"); - configuration.SetProperty("connection.connection_string", $"Data Source={path};Cache=Shared"); + configuration.SetProperty("connection.connection_string", ConnectionStringHelper.ConnectionStringFor(path)); return Fluently.Configure(configuration) .Mappings(cfg => cfg.FluentMappings.AddFromAssemblyOf()).BuildConfiguration(); diff --git a/src/MoBi.Core/Services/ProjectFileCompressor.cs b/src/MoBi.Core/Services/ProjectFileCompressor.cs index 941064abc..6a24320ea 100644 --- a/src/MoBi.Core/Services/ProjectFileCompressor.cs +++ b/src/MoBi.Core/Services/ProjectFileCompressor.cs @@ -1,6 +1,7 @@ -using System.Data.Common; -using Microsoft.Data.Sqlite; +using Microsoft.Data.Sqlite; using OSPSuite.Core.Extensions; +using OSPSuite.Infrastructure.Serialization.Extensions; +using System.Data.Common; namespace MoBi.Core.Services { @@ -14,7 +15,7 @@ public class ProjectFileCompressor : IProjectFileCompressor public void Compress(string projectFile) { var path = projectFile.ToUNCPath(); - using (var sqlLite = new SqliteConnection($"Data Source={path}")) + using (var sqlLite = new SqliteConnection(ConnectionStringHelper.ConnectionStringFor(path))) { sqlLite.Open(); vacuum(sqlLite); diff --git a/src/MoBi.Engine/MoBi.Engine.csproj b/src/MoBi.Engine/MoBi.Engine.csproj index 8c2d62c9d..462603874 100644 --- a/src/MoBi.Engine/MoBi.Engine.csproj +++ b/src/MoBi.Engine/MoBi.Engine.csproj @@ -28,8 +28,8 @@ - - + + diff --git a/src/MoBi.Presentation/MoBi.Presentation.csproj b/src/MoBi.Presentation/MoBi.Presentation.csproj index bf28c8e80..1200556ce 100644 --- a/src/MoBi.Presentation/MoBi.Presentation.csproj +++ b/src/MoBi.Presentation/MoBi.Presentation.csproj @@ -23,9 +23,9 @@ - - - + + + diff --git a/src/MoBi.R/MoBi.R.csproj b/src/MoBi.R/MoBi.R.csproj index 12cb3673e..b3bd524db 100644 --- a/src/MoBi.R/MoBi.R.csproj +++ b/src/MoBi.R/MoBi.R.csproj @@ -6,10 +6,10 @@ - - - - + + + + diff --git a/src/MoBi.UI/MoBi.UI.csproj b/src/MoBi.UI/MoBi.UI.csproj index 01ca81c2d..4c7962c93 100644 --- a/src/MoBi.UI/MoBi.UI.csproj +++ b/src/MoBi.UI/MoBi.UI.csproj @@ -26,11 +26,11 @@ - - - - - + + + + + diff --git a/src/MoBi/MoBi.csproj b/src/MoBi/MoBi.csproj index da7a4883e..4362e49ad 100644 --- a/src/MoBi/MoBi.csproj +++ b/src/MoBi/MoBi.csproj @@ -67,13 +67,13 @@ - + - + diff --git a/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj b/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj index 42bac6814..edc330446 100644 --- a/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj +++ b/tests/MoBi.HelpersForTests/MoBi.HelpersForTests.csproj @@ -6,7 +6,7 @@ - + diff --git a/tests/MoBi.Tests/MoBi.Tests.csproj b/tests/MoBi.Tests/MoBi.Tests.csproj index db86df7f5..d733facdd 100644 --- a/tests/MoBi.Tests/MoBi.Tests.csproj +++ b/tests/MoBi.Tests/MoBi.Tests.csproj @@ -38,9 +38,9 @@ - - - + + + diff --git a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj index 44fb362b5..e14415624 100644 --- a/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj +++ b/tests/MoBi.UI.Tests/MoBi.UI.Tests.csproj @@ -19,8 +19,8 @@ - - + + From 59815c0fd867d2b7922b2bee761ffe7af042fc51 Mon Sep 17 00:00:00 2001 From: Robert McIntosh <261477+rwmcintosh@users.noreply.github.com> Date: Mon, 10 Nov 2025 14:31:46 -0500 Subject: [PATCH 12/12] revert changes to tests --- .../IntegrationTests/SnapshotRunnerSpecs.cs | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs b/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs index b6c5e0e7b..f689f5d7d 100644 --- a/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs +++ b/tests/MoBi.Tests/IntegrationTests/SnapshotRunnerSpecs.cs @@ -23,8 +23,6 @@ public class when_exporting_a_snapshot_from_project : concern_for_SnapshotRunner private readonly string _projectFileName = "snapshot_no_pksim_modules.mbp3"; private string _jsonPath; private string _projectPath; - private IContextPersistor _contextPersistor; - private IMoBiContext _context; protected override void Context() { @@ -70,9 +68,9 @@ private void createProjectFromSnapshot() private void loadProject(string projectFile) { - _contextPersistor = IoC.Resolve(); - _context = IoC.Resolve(); - _contextPersistor.Load(_context, projectFile); + var contextPersistor = IoC.Resolve(); + var context = IoC.Resolve(); + contextPersistor.Load(context, projectFile); } protected override void Because() @@ -88,10 +86,6 @@ public void the_project_file_should_be_created() public override void Cleanup() { - // Close the project to release file handles before attempting to delete directories - if (_context != null) - _contextPersistor?.CloseProject(_context); - base.Cleanup(); if (Directory.Exists(_projectDirectory)) Directory.Delete(_projectDirectory, true); @@ -149,16 +143,6 @@ public void the_project_file_should_be_created() public override void Cleanup() { - // Close the project to release file handles before attempting to delete directories - // The batch runner loads the project into the shared singleton context and should close it, - // but ensure it's closed and connection pools are cleared in case of timing issues - var context = IoC.Resolve(); - if (context?.CurrentProject != null) - { - var contextPersistor = IoC.Resolve(); - contextPersistor?.CloseProject(context); - } - base.Cleanup(); if (Directory.Exists(_projectDirectory)) Directory.Delete(_projectDirectory, true);