From 19581135c9cb04f92d4e5f63c5e1f5fe65547f34 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sun, 2 Jun 2019 21:50:28 +0200 Subject: [PATCH 01/56] Create FUNDING.yml --- .github/FUNDING.yml | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..f56cbde --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,3 @@ +# These are supported funding model platforms + +github: [msallin] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] From 0b988a03c64615cc4dcf429c5baa7ef3c7ca77a2 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sun, 2 Jun 2019 21:52:21 +0200 Subject: [PATCH 02/56] Update FUNDING.yml --- .github/FUNDING.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index f56cbde..0901f69 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,3 +1,3 @@ # These are supported funding model platforms -github: [msallin] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: msallin # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] From ca193d473504dadfdda908346c11e4d44f09ed07 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 11 Jun 2019 22:20:27 +0200 Subject: [PATCH 03/56] Update NuGet-Packages to the newest version --- .../SQLite.CodeFirst.Console.csproj | 8 ++++---- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 76841ab..57f796d 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -11,10 +11,10 @@ - - - - + + + + diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 149061f..e292df6 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -15,12 +15,12 @@ - - - - - - + + + + + + From 4073694ec308379e469f875d2e61d23bda3da39f Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 11 Jun 2019 22:21:17 +0200 Subject: [PATCH 04/56] Set Console and Test project target framework to net48 --- README.md | 1 + SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj | 2 +- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 2 +- 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d24d114..b0dc9d4 100644 --- a/README.md +++ b/README.md @@ -42,6 +42,7 @@ You can use the SQLite CodeFirst in projects that target the following framework - .NET 4.7 (use net45) - .NET 4.7.1 (use net45) - .NET 4.7.2 (use net45) +- .NET 4.8 (uses net45) ## How to use The functionality is exposed by using implementations of the `IDbInitializer<>` interface. diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 57f796d..5ac83b7 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -1,7 +1,7 @@  Exe - net472 + net48 SQLite.CodeFirst A console application which demonstrates how to use SQLite.CodeFirst. 1.0.0.0 diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index e292df6..caf835b 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -1,6 +1,6 @@  - net472 + net48 SQLite.CodeFirst.Test Contains the Unit Tests for the SQLite.CodeFirst Library. 1.0.0.0 From c82ff247640402c6fb23df5073333cb081ec07ca Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 11 Jun 2019 22:21:43 +0200 Subject: [PATCH 05/56] Fix some markdown issues in the read me and correct typos --- README.md | 47 ++++++++++++++++++++++++++++++----------------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/README.md b/README.md index b0dc9d4..8b4164c 100644 --- a/README.md +++ b/README.md @@ -7,15 +7,17 @@ Creates a [SQLite Database](https://sqlite.org/) from Code, using [Entity Framework](https://msdn.microsoft.com/en-us/data/ef.aspx) CodeFirst. ## Support the project PayPal donate button + To support this project you can: *star the repository*, report bugs/request features by creating new issues, write code and create PRs or donate. Especially if you use it for a commercial project, a donation is welcome. -If you need a specific feature for a commercial project, I am glad to offer a paid implementation. - +If you need a specific feature for a commercial project, I am glad to offer a paid implementation. ## Features -This Project ships several `IDbInitializer` classes. These create new SQLite Databases based on your model/code. + +This project ships several `IDbInitializer` classes. These create new SQLite Databases based on your model/code. The following features are supported: + - Tables from classes (supported annotations: `Table`) - Columns from properties (supported annotations: `Column`, `Key`, `MaxLength`, `Required`, `NotMapped`, `DatabaseGenerated`, `Index`) - PrimaryKey constraint (`Key` annotation, key composites are supported) @@ -32,21 +34,24 @@ Either get the assembly from the latest [GitHub Release Page](https://github.com The project is built to target .NET framework versions 4.0 and 4.5. You can use the SQLite CodeFirst in projects that target the following frameworks: -- .NET 4.0 (use net40) -- .NET 4.5 (use net45) -- .NET 4.5.1 (use net45) -- .NET 4.5.2 (use net45) -- .NET 4.6 (use net45) -- .NET 4.6.1 (use net45) -- .NET 4.6.2 (use net45) -- .NET 4.7 (use net45) -- .NET 4.7.1 (use net45) -- .NET 4.7.2 (use net45) + +- .NET 4.0 (uses net40) +- .NET 4.5 (uses net45) +- .NET 4.5.1 (uses net45) +- .NET 4.5.2 (uses net45) +- .NET 4.6 (uses net45) +- .NET 4.6.1 (uses net45) +- .NET 4.6.2 (uses net45) +- .NET 4.7 (uses net45) +- .NET 4.7.1 (uses net45) +- .NET 4.7.2 (uses net45) - .NET 4.8 (uses net45) ## How to use + The functionality is exposed by using implementations of the `IDbInitializer<>` interface. Depending on your need, you can choose from the following initializers: + - SqliteCreateDatabaseIfNotExists - SqliteDropCreateDatabaseAlways - SqliteDropCreateDatabaseWhenModelChanges @@ -57,6 +62,7 @@ Or for even more control, use the `SqliteSqlGenerator` (implements `ISqlGenerato When you want to let the Entity Framework create database if it does not exist, just set `SqliteDropCreateDatabaseAlways<>` or `SqliteCreateDatabaseIfNotExists<>` as your `IDbInitializer<>`. ### Initializer Sample + ```csharp public class MyDbContext : DbContext { @@ -70,13 +76,15 @@ public class MyDbContext : DbContext } } ``` + Notice that the `SqliteDropCreateDatabaseWhenModelChanges<>` initializer will create a additional table in your database. This table is used to store some information to detect model changes. If you want to use a own entity/table you can implement the -`IHistory` interface and pass the type of your entity as parameter in the to the constructor from the initializer. +`IHistory` interface and pass the type of your entity as parameter in the to the constructor from the initializer. In a more advanced scenario, you may want to populate some core- or test-data after the database was created. To do this, inherit from `SqliteDropCreateDatabaseAlways<>`, `SqliteCreateDatabaseIfNotExists<>` or `SqliteDropCreateDatabaseWhenModelChanges<>` and override the `Seed(MyDbContext context)` function. This function will be called in a transaction once the database was created. This function is only executed if a new database was successfully created. + ```csharp public class MyDbContextInitializer : SqliteDropCreateDatabaseAlways { @@ -91,6 +99,7 @@ public class MyDbContextInitializer : SqliteDropCreateDatabaseAlways ## Recognition -I started with the [code](https://gist.github.com/flaub/1968486e1b3f2b9fddaf) from [flaub](https://github.com/flaub). + +I started with the [code](https://gist.github.com/flaub/1968486e1b3f2b9fddaf) from [flaub](https://github.com/flaub). From 4f30a0184ea5f2c64f32831da478bb869d74778e Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 15 Jun 2019 22:25:27 +0200 Subject: [PATCH 06/56] Update README.md Fix some grammer mistakes --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 8b4164c..21e5e9f 100644 --- a/README.md +++ b/README.md @@ -78,12 +78,12 @@ public class MyDbContext : DbContext ``` Notice that the `SqliteDropCreateDatabaseWhenModelChanges<>` initializer will create a additional table in your database. -This table is used to store some information to detect model changes. If you want to use a own entity/table you can implement the -`IHistory` interface and pass the type of your entity as parameter in the to the constructor from the initializer. +This table is used to store some information to detect model changes. If you want to use an own entity/table you have to implement the +`IHistory` interface and pass the type of your entity as parameter to the constructor of the initializer. In a more advanced scenario, you may want to populate some core- or test-data after the database was created. To do this, inherit from `SqliteDropCreateDatabaseAlways<>`, `SqliteCreateDatabaseIfNotExists<>` or `SqliteDropCreateDatabaseWhenModelChanges<>` and override the `Seed(MyDbContext context)` function. -This function will be called in a transaction once the database was created. This function is only executed if a new database was successfully created. +This function will be called in a transaction, once the database was created. This function is only executed if a new database was successfully created. ```csharp public class MyDbContextInitializer : SqliteDropCreateDatabaseAlways From a8394346c380d991d51cb2a2b12a37a32450a309 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 14 Nov 2019 15:14:14 +0100 Subject: [PATCH 07/56] Update NuGet-Packages --- SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj | 6 +----- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 6 +----- SQLite.CodeFirst.sln | 4 ++-- SQLite.CodeFirst/SQLite.CodeFirst.csproj | 2 +- 4 files changed, 5 insertions(+), 13 deletions(-) diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 5ac83b7..0b88383 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -10,11 +10,7 @@ ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - - - - - + diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index caf835b..8bfbf43 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -14,15 +14,11 @@ pdbonly - - - - - + diff --git a/SQLite.CodeFirst.sln b/SQLite.CodeFirst.sln index c1ff1b3..2cffe5d 100644 --- a/SQLite.CodeFirst.sln +++ b/SQLite.CodeFirst.sln @@ -1,6 +1,6 @@ Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 15 -VisualStudioVersion = 15.0.28010.2050 +# Visual Studio Version 16 +VisualStudioVersion = 16.0.29503.13 MinimumVisualStudioVersion = 10.0.40219.1 Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite.CodeFirst", "SQLite.CodeFirst\SQLite.CodeFirst.csproj", "{50A32FE4-0E13-4213-A373-72523CDF34D9}" EndProject diff --git a/SQLite.CodeFirst/SQLite.CodeFirst.csproj b/SQLite.CodeFirst/SQLite.CodeFirst.csproj index 21ebe59..9093b53 100644 --- a/SQLite.CodeFirst/SQLite.CodeFirst.csproj +++ b/SQLite.CodeFirst/SQLite.CodeFirst.csproj @@ -20,7 +20,7 @@ - + From e9ef7cf6532c91b61ab7411f08547216366f6321 Mon Sep 17 00:00:00 2001 From: Thomas Zeugner Date: Thu, 14 Nov 2019 13:58:30 +0100 Subject: [PATCH 08/56] Make DeleteDatabase in DropCreateDatabaseWhenModelChanges virtual To allow custumer deleting of database --- .../SqliteDropCreateDatabaseWhenModelChanges.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index f47feea..ddaaff5 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -79,6 +79,7 @@ public override void InitializeDatabase(TContext context) } FileAttributes? attributes = InMemoryAwareFile.GetFileAttributes(databseFilePath); + CloseDatabase(context, databseFilePath); DeleteDatabase(context, databseFilePath); base.InitializeDatabase(context); InMemoryAwareFile.SetFileAttributes(databseFilePath, attributes); @@ -91,13 +92,16 @@ public override void InitializeDatabase(TContext context) } } + protected virtual void DeleteDatabase(TContext context, string databseFilePath) { + InMemoryAwareFile.Delete(databseFilePath); + } + [SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.GC.Collect", Justification = "Required.")] - private static void DeleteDatabase(TContext context, string databseFilePath) + private static void CloseDatabase(TContext context, string databseFilePath) { context.Database.Connection.Close(); GC.Collect(); GC.WaitForPendingFinalizers(); - InMemoryAwareFile.Delete(databseFilePath); } private void SaveHistory(TContext context) From 04acef35e38bd0164b4b4ad30fd1f4ff7b612082 Mon Sep 17 00:00:00 2001 From: Thomas Ze Date: Fri, 15 Nov 2019 08:30:45 +0100 Subject: [PATCH 09/56] fix style and typo --- ...qliteDropCreateDatabaseWhenModelChanges.cs | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index ddaaff5..cf2c95c 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -68,9 +68,9 @@ protected void ConfigureHistoryEntity() /// The context. public override void InitializeDatabase(TContext context) { - string databseFilePath = GetDatabasePathFromContext(context); + string databaseFilePath = GetDatabasePathFromContext(context); - bool dbExists = InMemoryAwareFile.Exists(databseFilePath); + bool dbExists = InMemoryAwareFile.Exists(databaseFilePath); if (dbExists) { if (IsSameModel(context)) @@ -78,11 +78,11 @@ public override void InitializeDatabase(TContext context) return; } - FileAttributes? attributes = InMemoryAwareFile.GetFileAttributes(databseFilePath); - CloseDatabase(context, databseFilePath); - DeleteDatabase(context, databseFilePath); + FileAttributes? attributes = InMemoryAwareFile.GetFileAttributes(databaseFilePath); + CloseDatabase(context, databaseFilePath); + DeleteDatabase(context, databaseFilePath); base.InitializeDatabase(context); - InMemoryAwareFile.SetFileAttributes(databseFilePath, attributes); + InMemoryAwareFile.SetFileAttributes(databaseFilePath, attributes); SaveHistory(context); } else @@ -92,12 +92,18 @@ public override void InitializeDatabase(TContext context) } } - protected virtual void DeleteDatabase(TContext context, string databseFilePath) { - InMemoryAwareFile.Delete(databseFilePath); + /// + /// Called to drop/remove Database file from disk. + /// + /// The context. + /// Filename of Database to be removed. + protected virtual void DeleteDatabase(TContext context, string databaseFilePath) + { + InMemoryAwareFile.Delete(databaseFilePath); } [SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.GC.Collect", Justification = "Required.")] - private static void CloseDatabase(TContext context, string databseFilePath) + private static void CloseDatabase(TContext context, string databaseFilePath) { context.Database.Connection.Close(); GC.Collect(); From 0963736eaefea08cbda0cca3ed2e078c1d8c1a3e Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 16 Nov 2019 19:21:43 +0100 Subject: [PATCH 10/56] Remove unused parameter from CloseDatabase method --- .../SqliteDropCreateDatabaseWhenModelChanges.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index cf2c95c..cfca195 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -79,7 +79,7 @@ public override void InitializeDatabase(TContext context) } FileAttributes? attributes = InMemoryAwareFile.GetFileAttributes(databaseFilePath); - CloseDatabase(context, databaseFilePath); + CloseDatabase(context); DeleteDatabase(context, databaseFilePath); base.InitializeDatabase(context); InMemoryAwareFile.SetFileAttributes(databaseFilePath, attributes); @@ -103,7 +103,7 @@ protected virtual void DeleteDatabase(TContext context, string databaseFilePath) } [SuppressMessage("Microsoft.Reliability", "CA2001:AvoidCallingProblematicMethods", MessageId = "System.GC.Collect", Justification = "Required.")] - private static void CloseDatabase(TContext context, string databaseFilePath) + private static void CloseDatabase(TContext context) { context.Database.Connection.Close(); GC.Collect(); From 68abb4d6ae1e71d17708a3f1e18eabd6cb4f2773 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 16 Nov 2019 19:23:26 +0100 Subject: [PATCH 11/56] Fix typo in comment of SqliteDropCreateDatabaseWhenModelChanges class --- .../DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index cfca195..d83c3a9 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -61,7 +61,7 @@ protected void ConfigureHistoryEntity() /// /// Initialize the database for the given context. - /// Generates the SQLite-DDL from the model and executs it against the database. + /// Generates the SQLite-DDL from the model and executes it against the database. /// After that the method is executed. /// All actions are be executed in transactions. /// From 221804582004fcf35c1c04fa868f72421a9fcd78 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 16 Nov 2019 19:29:34 +0100 Subject: [PATCH 12/56] Set version to 1.5.3 --- release_appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_appveyor.yml b/release_appveyor.yml index 17a1e42..402be71 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,4 +1,4 @@ -version: 1.5.2.{build} +version: 1.5.3.{build} image: Visual Studio 2017 branches: only: From 207e1e46bb444880c52d11b968b7946c9d508a27 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 14 Nov 2019 15:59:07 +0100 Subject: [PATCH 13/56] #143: Add netstandard2.1 support --- README.md | 21 +++++++-------------- SQLite.CodeFirst.sln | 1 + SQLite.CodeFirst/SQLite.CodeFirst.csproj | 2 +- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 21e5e9f..bbe4c73 100644 --- a/README.md +++ b/README.md @@ -30,29 +30,22 @@ The following features are supported: - SQL default value (Decorate columns with the `SqlDefaultValueAttribute`, which is part of this library) ## Install + Either get the assembly from the latest [GitHub Release Page](https://github.com/msallin/SQLiteCodeFirst/releases) or install the NuGet-Package [SQLite.CodeFirst](https://www.nuget.org/packages/SQLite.CodeFirst/) (`PM> Install-Package SQLite.CodeFirst`). -The project is built to target .NET framework versions 4.0 and 4.5. +The project is built to target .NET framework versions 4.0 and 4.5 and .NET Standard 2.1. You can use the SQLite CodeFirst in projects that target the following frameworks: - .NET 4.0 (uses net40) -- .NET 4.5 (uses net45) -- .NET 4.5.1 (uses net45) -- .NET 4.5.2 (uses net45) -- .NET 4.6 (uses net45) -- .NET 4.6.1 (uses net45) -- .NET 4.6.2 (uses net45) -- .NET 4.7 (uses net45) -- .NET 4.7.1 (uses net45) -- .NET 4.7.2 (uses net45) -- .NET 4.8 (uses net45) +- .NET 4.5-4.8 (uses net45) +- .NET Core 3.0-3.1 (uses netstandard2.1) ## How to use The functionality is exposed by using implementations of the `IDbInitializer<>` interface. Depending on your need, you can choose from the following initializers: -- SqliteCreateDatabaseIfNotExists +- SqliteCreateDatabaseIfNotExists - SqliteDropCreateDatabaseAlways - SqliteDropCreateDatabaseWhenModelChanges @@ -68,7 +61,7 @@ public class MyDbContext : DbContext { public MyDbContext() : base("ConnectionStringName") { } - + protected override void OnModelCreating(DbModelBuilder modelBuilder) { var sqliteConnectionInitializer = new SqliteCreateDatabaseIfNotExists(modelBuilder); @@ -130,7 +123,7 @@ public class MyContext : DbContext The code is written in an extensible way. The logic is divided into two main parts, Builder and Statement. -The Builder knows how to translate the EdmModel into statements where a statement class creates the SQLite-DDL-Code. +The Builder knows how to translate the EdmModel into statements where a statement class creates the SQLite-DDL-Code. The structure of the statements is influenced by the [SQLite Language Specification](https://www.sqlite.org/lang.html). You will find an extensive usage of the composite pattern. diff --git a/SQLite.CodeFirst.sln b/SQLite.CodeFirst.sln index 2cffe5d..9d1e816 100644 --- a/SQLite.CodeFirst.sln +++ b/SQLite.CodeFirst.sln @@ -16,6 +16,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite.CodeFirst.Test", "SQ EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{1F6D4E0E-5D07-4889-961A-A6AFC0ECD7C7}" ProjectSection(SolutionItems) = preProject + README.md = README.md Shared\SQLite.CodeFirst.ruleset = Shared\SQLite.CodeFirst.ruleset Shared\SQLite.CodeFirst.StrongNameKey.snk = Shared\SQLite.CodeFirst.StrongNameKey.snk EndProjectSection diff --git a/SQLite.CodeFirst/SQLite.CodeFirst.csproj b/SQLite.CodeFirst/SQLite.CodeFirst.csproj index 9093b53..5d86a57 100644 --- a/SQLite.CodeFirst/SQLite.CodeFirst.csproj +++ b/SQLite.CodeFirst/SQLite.CodeFirst.csproj @@ -1,7 +1,7 @@  - net40;net45 + net40;net45;netstandard2.1 Marc Sallin From 6065baf36b9c9fa62420df2173f65769445aa65f Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 14 Nov 2019 15:59:38 +0100 Subject: [PATCH 14/56] #143: Add .NET Core 3.1 console project --- .../Entity/Coach.cs | 7 + .../Entity/CustomHistory.cs | 12 ++ .../Entity/Foo.cs | 41 +++++ .../Entity/FooCompositeKey.cs | 25 +++ .../Entity/FooRelationshipA.cs | 18 +++ .../Entity/FooRelationshipB.cs | 18 +++ .../Entity/FooSelf.cs | 13 ++ .../Entity/FooStep.cs | 13 ++ .../Entity/IEntity.cs | 7 + .../Entity/Person.cs | 28 ++++ .../Entity/Player.cs | 21 +++ .../Entity/Stadion.cs | 26 ++++ .../Entity/Team.cs | 22 +++ .../FootballDbContext.cs | 33 ++++ .../FootballDbInitializer.cs | 17 ++ .../ModelConfiguration.cs | 66 ++++++++ SQLite.CodeFirst.NetCore.Console/Program.cs | 147 ++++++++++++++++++ .../SQLite.CodeFirst.NetCore.Console.csproj | 16 ++ SQLite.CodeFirst.sln | 6 + 19 files changed, 536 insertions(+) create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/Coach.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/CustomHistory.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/Foo.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/FooSelf.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/FooStep.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/Person.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/Player.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/Stadion.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Entity/Team.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/FootballDbContext.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/FootballDbInitializer.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/ModelConfiguration.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/Program.cs create mode 100644 SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/Coach.cs b/SQLite.CodeFirst.NetCore.Console/Entity/Coach.cs new file mode 100644 index 0000000..6dfc65b --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/Coach.cs @@ -0,0 +1,7 @@ +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + public class Coach : Person + { + public virtual Team Team { get; set; } + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/CustomHistory.cs b/SQLite.CodeFirst.NetCore.Console/Entity/CustomHistory.cs new file mode 100644 index 0000000..740c3da --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/CustomHistory.cs @@ -0,0 +1,12 @@ +using System; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + public class CustomHistory : IHistory + { + public int Id { get; set; } + public string Hash { get; set; } + public string Context { get; set; } + public DateTime CreateDate { get; set; } + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/Foo.cs b/SQLite.CodeFirst.NetCore.Console/Entity/Foo.cs new file mode 100644 index 0000000..f5a1bdd --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/Foo.cs @@ -0,0 +1,41 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations.Schema; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/69 and https://github.com/msallin/SQLiteCodeFirst/issues/63 + /// + public class Foo + { + private ICollection _fooSelves; + private ICollection _fooSteps; + + public int FooId { get; set; } + public string Name { get; set; } + public int? FooSelf1Id { get; set; } + public int? FooSelf2Id { get; set; } + public int? FooSelf3Id { get; set; } + + [ForeignKey("FooSelf1Id")] + public virtual Foo ParentMyEntity1 { get; set; } + + [ForeignKey("FooSelf2Id")] + public virtual Foo ParentMyEntity2 { get; set; } + + [ForeignKey("FooSelf3Id")] + public virtual Foo ParentMyEntity3 { get; set; } + + public virtual ICollection FooSteps + { + get { return _fooSteps ?? (_fooSteps = new HashSet()); } + set { _fooSteps = value; } + } + + public virtual ICollection FooSelves + { + get { return _fooSelves ?? (_fooSelves = new HashSet()); } + set { _fooSelves = value; } + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs new file mode 100644 index 0000000..4020e52 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs @@ -0,0 +1,25 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooCompositeKey + { + [Key, Column(Order = 1)] + public int Id { get; set; } + + [Key, Column(Order = 2), StringLength(20)] + public string Version { get; set; } + + [StringLength(255)] + public string Name { get; set; } + + public virtual ICollection FooeyACollection { get; set; } + + public virtual ICollection FooeyBCollection { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs new file mode 100644 index 0000000..135b3bd --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooRelationshipA + { + public int Id { get; set; } + + [StringLength(255)] + public string Name { get; set; } + + public virtual ICollection Fooey { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs new file mode 100644 index 0000000..4997660 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs @@ -0,0 +1,18 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooRelationshipB + { + public int Id { get; set; } + + [StringLength(255)] + public string Name { get; set; } + + public virtual ICollection Fooey { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooSelf.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooSelf.cs new file mode 100644 index 0000000..6a8ad39 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooSelf.cs @@ -0,0 +1,13 @@ +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/69 and https://github.com/msallin/SQLiteCodeFirst/issues/63 + /// + public class FooSelf + { + public int FooSelfId { get; set; } + public int FooId { get; set; } + public int Number { get; set; } + public virtual Foo Foo { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooStep.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooStep.cs new file mode 100644 index 0000000..b13b3a4 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooStep.cs @@ -0,0 +1,13 @@ +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/69 and https://github.com/msallin/SQLiteCodeFirst/issues/63 + /// + public class FooStep + { + public int FooStepId { get; set; } + public int FooId { get; set; } + public int Number { get; set; } + public virtual Foo Foo { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs b/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs new file mode 100644 index 0000000..a33e2b6 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs @@ -0,0 +1,7 @@ +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + interface IEntity + { + int Id { get; set; } + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/Person.cs b/SQLite.CodeFirst.NetCore.Console/Entity/Person.cs new file mode 100644 index 0000000..e5ebda4 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/Person.cs @@ -0,0 +1,28 @@ +using System; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + public abstract class Person : IEntity + { + public int Id { get; set; } + + [MaxLength(50)] + [Collate(CollationFunction.NoCase)] + public string FirstName { get; set; } + + [MaxLength(50)] + public string LastName { get; set; } + + [MaxLength(100)] + public string Street { get; set; } + + [Required] + public string City { get; set; } + + [DatabaseGenerated(DatabaseGeneratedOption.Computed)] + [SqlDefaultValue(DefaultValue = "DATETIME('now')")] + public DateTime CreatedUtc { get; set; } + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/Player.cs b/SQLite.CodeFirst.NetCore.Console/Entity/Player.cs new file mode 100644 index 0000000..f642654 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/Player.cs @@ -0,0 +1,21 @@ +using System.ComponentModel.DataAnnotations.Schema; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + [Table("TeamPlayer")] + public class Player : Person + { + [Index] // Automatically named 'IX_TeamPlayer_Number' + [Index("IX_TeamPlayer_NumberPerTeam", Order = 1, IsUnique = true)] + public int Number { get; set; } + + // The index attribute must be placed on the FK not on the navigation property (team). + [Index("IX_TeamPlayer_NumberPerTeam", Order = 2, IsUnique = true)] + public int TeamId { get; set; } + + // Its not possible to set an index on this property. Use the FK property (teamId). + public virtual Team Team { get; set; } + + public virtual Player Mentor { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/Stadion.cs b/SQLite.CodeFirst.NetCore.Console/Entity/Stadion.cs new file mode 100644 index 0000000..d8a2c50 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/Stadion.cs @@ -0,0 +1,26 @@ +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + public class Stadion + { + [Key] + [Column(Order = 1)] + [Index("IX_Stadion_Main", Order = 2, IsUnique = true)] // Test for combined, named index + public string Name { get; set; } + + [Key] + [Column(Order = 2)] + [Index("IX_Stadion_Main", Order = 1, IsUnique = true)] // Test for combined, named index + public string Street { get; set; } + + [Key] + [Column(Order = 3)] + public string City { get; set; } + + [Column(Order = 4)] + [Index("ReservedKeyWordTest", IsUnique = true)] + public int Order { get; set; } + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/Team.cs b/SQLite.CodeFirst.NetCore.Console/Entity/Team.cs new file mode 100644 index 0000000..d448a5f --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Entity/Team.cs @@ -0,0 +1,22 @@ +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +namespace SQLite.CodeFirst.NetCore.Console.Entity +{ + public class Team : IEntity + { + [Autoincrement] + public int Id { get; set; } + + [Index("IX_Team_TeamsName")] // Test for named index. + [Required] + public string Name { get; set; } + + public virtual Coach Coach { get; set; } + + public virtual ICollection Players { get; set; } + + public virtual Stadion Stadion { get; set; } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/FootballDbContext.cs b/SQLite.CodeFirst.NetCore.Console/FootballDbContext.cs new file mode 100644 index 0000000..330c6c0 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/FootballDbContext.cs @@ -0,0 +1,33 @@ +using System.Data.Common; +using System.Data.Entity; + +namespace SQLite.CodeFirst.NetCore.Console +{ + public class FootballDbContext : DbContext + { + public FootballDbContext(string nameOrConnectionString) + : base(nameOrConnectionString) + { + Configure(); + } + + public FootballDbContext(DbConnection connection, bool contextOwnsConnection) + : base(connection, contextOwnsConnection) + { + Configure(); + } + + private void Configure() + { + Configuration.ProxyCreationEnabled = true; + Configuration.LazyLoadingEnabled = true; + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + ModelConfiguration.Configure(modelBuilder); + var initializer = new FootballDbInitializer(modelBuilder); + Database.SetInitializer(initializer); + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/FootballDbInitializer.cs b/SQLite.CodeFirst.NetCore.Console/FootballDbInitializer.cs new file mode 100644 index 0000000..0d4a426 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/FootballDbInitializer.cs @@ -0,0 +1,17 @@ +using System.Data.Entity; +using SQLite.CodeFirst.NetCore.Console.Entity; + +namespace SQLite.CodeFirst.NetCore.Console +{ + public class FootballDbInitializer : SqliteDropCreateDatabaseWhenModelChanges + { + public FootballDbInitializer(DbModelBuilder modelBuilder) + : base(modelBuilder, typeof(CustomHistory)) + { } + + protected override void Seed(FootballDbContext context) + { + // Here you can seed your core data if you have any. + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/ModelConfiguration.cs b/SQLite.CodeFirst.NetCore.Console/ModelConfiguration.cs new file mode 100644 index 0000000..254f6f8 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/ModelConfiguration.cs @@ -0,0 +1,66 @@ +using System.Data.Entity; +using SQLite.CodeFirst.NetCore.Console.Entity; + +namespace SQLite.CodeFirst.NetCore.Console +{ + public class ModelConfiguration + { + public static void Configure(DbModelBuilder modelBuilder) + { + ConfigureTeamEntity(modelBuilder); + ConfigureStadionEntity(modelBuilder); + ConfigureCoachEntity(modelBuilder); + ConfigurePlayerEntity(modelBuilder); + ConfigureSelfReferencingEntities(modelBuilder); + ConfigureCompositeKeyEntities(modelBuilder); + } + + private static void ConfigureTeamEntity(DbModelBuilder modelBuilder) + { + modelBuilder.Entity().ToTable("Base.MyTable") + .HasRequired(t => t.Coach) + .WithMany() + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .HasRequired(t => t.Stadion) + .WithRequiredPrincipal() + .WillCascadeOnDelete(true); + } + + private static void ConfigureStadionEntity(DbModelBuilder modelBuilder) + { + modelBuilder.Entity(); + } + + private static void ConfigureCoachEntity(DbModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasRequired(p => p.Team) + .WithRequiredPrincipal(t => t.Coach) + .WillCascadeOnDelete(false); + } + + private static void ConfigurePlayerEntity(DbModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasRequired(p => p.Team) + .WithMany(team => team.Players) + .WillCascadeOnDelete(true); + } + + private static void ConfigureSelfReferencingEntities(DbModelBuilder modelBuilder) + { + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + } + + private static void ConfigureCompositeKeyEntities(DbModelBuilder modelBuilder) + { + modelBuilder.Entity(); + modelBuilder.Entity(); + modelBuilder.Entity(); + } + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Program.cs b/SQLite.CodeFirst.NetCore.Console/Program.cs new file mode 100644 index 0000000..cc622cd --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Program.cs @@ -0,0 +1,147 @@ +using System.Collections.Generic; +using System.Data.Entity; +using System.Data.SQLite; +using System.Linq; +using SQLite.CodeFirst.NetCore.Console.Entity; + +namespace SQLite.CodeFirst.NetCore.Console +{ + public static class Program + { + private static void Main() + { + StartDemoUseInMemory(); + StartDemoUseFile(); + PressEnterToExit(); + } + + private static void StartDemoUseInMemory() + { + System.Console.WriteLine("Starting Demo Application (In Memory)"); + System.Console.WriteLine(string.Empty); + + using (var sqLiteConnection = new SQLiteConnection("data source=:memory:")) + { + // This is required if a in memory db is used. + sqLiteConnection.Open(); + + using (var context = new FootballDbContext(sqLiteConnection, false)) + { + CreateAndSeedDatabase(context); + DisplaySeededData(context); + } + } + } + + private static void StartDemoUseFile() + { + System.Console.WriteLine("Starting Demo Application (File)"); + System.Console.WriteLine(string.Empty); + + using (var context = new FootballDbContext("footballDb")) + { + CreateAndSeedDatabase(context); + DisplaySeededData(context); + } + } + + private static void CreateAndSeedDatabase(DbContext context) + { + System.Console.WriteLine("Create and seed the database."); + + if (context.Set().Count() != 0) + { + return; + } + + context.Set().Add(new Team + { + Name = "YB", + Coach = new Coach + { + City = "Zürich", + FirstName = "Masssaman", + LastName = "Nachn", + Street = "Testingstreet 844" + }, + Players = new List + { + new Player + { + City = "Bern", + FirstName = "Marco", + LastName = "Bürki", + Street = "Wunderstrasse 43", + Number = 12 + }, + new Player + { + City = "Berlin", + FirstName = "Alain", + LastName = "Rochat", + Street = "Wonderstreet 13", + Number = 14 + } + }, + Stadion = new Stadion + { + Name = "Stade de Suisse", + City = "Bern", + Street = "Papiermühlestrasse 71" + } + }); + + context.SaveChanges(); + + System.Console.WriteLine("Completed."); + System.Console.WriteLine(); + } + + private static void DisplaySeededData(DbContext context) + { + System.Console.WriteLine("Display seeded data."); + + foreach (Team team in context.Set()) + { + System.Console.WriteLine("\t Team:"); + System.Console.WriteLine("\t Id: {0}", team.Id); + System.Console.WriteLine("\t Name: {0}", team.Name); + System.Console.WriteLine(); + + System.Console.WriteLine("\t\t Stadion:"); + System.Console.WriteLine("\t\t Name: {0}", team.Stadion.Name); + System.Console.WriteLine("\t\t Street: {0}", team.Stadion.Street); + System.Console.WriteLine("\t\t City: {0}", team.Stadion.City); + System.Console.WriteLine(); + + System.Console.WriteLine("\t\t Coach:"); + System.Console.WriteLine("\t\t Id: {0}", team.Coach.Id); + System.Console.WriteLine("\t\t FirstName: {0}", team.Coach.FirstName); + System.Console.WriteLine("\t\t LastName: {0}", team.Coach.LastName); + System.Console.WriteLine("\t\t Street: {0}", team.Coach.Street); + System.Console.WriteLine("\t\t City: {0}", team.Coach.City); + System.Console.WriteLine(); + + foreach (Player player in team.Players) + { + System.Console.WriteLine("\t\t Player:"); + System.Console.WriteLine("\t\t Id: {0}", player.Id); + System.Console.WriteLine("\t\t Number: {0}", player.Number); + System.Console.WriteLine("\t\t FirstName: {0}", player.FirstName); + System.Console.WriteLine("\t\t LastName: {0}", player.LastName); + System.Console.WriteLine("\t\t Street: {0}", player.Street); + System.Console.WriteLine("\t\t City: {0}", player.City); + System.Console.WriteLine("\t\t Created: {0}", player.CreatedUtc); + System.Console.WriteLine(); + } + } + } + + private static void PressEnterToExit() + { + System.Console.WriteLine(); + System.Console.WriteLine("Press 'Enter' to exit."); + System.Console.ReadLine(); + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj new file mode 100644 index 0000000..d09eb1b --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj @@ -0,0 +1,16 @@ + + + + Exe + netcoreapp3.1 + + + + + + + + + + + diff --git a/SQLite.CodeFirst.sln b/SQLite.CodeFirst.sln index 9d1e816..856e8f8 100644 --- a/SQLite.CodeFirst.sln +++ b/SQLite.CodeFirst.sln @@ -21,6 +21,8 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{1F6D4E Shared\SQLite.CodeFirst.StrongNameKey.snk = Shared\SQLite.CodeFirst.StrongNameKey.snk EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite.CodeFirst.NetCore.Console", "SQLite.CodeFirst.NetCore.Console\SQLite.CodeFirst.NetCore.Console.csproj", "{709F46E3-D23B-4931-9985-8E09E3817CC4}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -39,6 +41,10 @@ Global {E542F38D-852E-489D-81C2-BF333503E10F}.Debug|Any CPU.Build.0 = Debug|Any CPU {E542F38D-852E-489D-81C2-BF333503E10F}.Release|Any CPU.ActiveCfg = Release|Any CPU {E542F38D-852E-489D-81C2-BF333503E10F}.Release|Any CPU.Build.0 = Release|Any CPU + {709F46E3-D23B-4931-9985-8E09E3817CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {709F46E3-D23B-4931-9985-8E09E3817CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU + {709F46E3-D23B-4931-9985-8E09E3817CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU + {709F46E3-D23B-4931-9985-8E09E3817CC4}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE From 52b9b7c195a2e62deb4a9fc37dc0bdd40687cecf Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 14 Nov 2019 16:03:30 +0100 Subject: [PATCH 15/56] #143: Use Appveyor image "Visual Studio 2019" to build .NET Core 3.1 --- ci_appveyor.yml | 2 +- release_appveyor.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/ci_appveyor.yml b/ci_appveyor.yml index 3a96f64..bc7ecb2 100644 --- a/ci_appveyor.yml +++ b/ci_appveyor.yml @@ -1,5 +1,5 @@ version: CI_{branch}_{build} -image: Visual Studio 2017 +image: Visual Studio 2019 skip_tags: true configuration: - Release diff --git a/release_appveyor.yml b/release_appveyor.yml index 402be71..1e430cf 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,5 +1,5 @@ version: 1.5.3.{build} -image: Visual Studio 2017 +image: Visual Studio 2019 branches: only: - master From 4533a9cda95fe0096b715f98c30b4bea5b4aa06e Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 26 Dec 2019 12:38:58 +0100 Subject: [PATCH 16/56] #143: Update NuGet packages --- .../SQLite.CodeFirst.Console.csproj | 2 +- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 10 +++++----- SQLite.CodeFirst/SQLite.CodeFirst.csproj | 2 +- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 0b88383..3c1470a 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -10,7 +10,7 @@ ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - + diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 8bfbf43..0dacc17 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -14,11 +14,11 @@ pdbonly - - - - - + + + + + diff --git a/SQLite.CodeFirst/SQLite.CodeFirst.csproj b/SQLite.CodeFirst/SQLite.CodeFirst.csproj index 5d86a57..a723f64 100644 --- a/SQLite.CodeFirst/SQLite.CodeFirst.csproj +++ b/SQLite.CodeFirst/SQLite.CodeFirst.csproj @@ -20,7 +20,7 @@ - + From 0a2bc9fca74f949f109edefb10e033eb7e015ccf Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sun, 17 Nov 2019 20:09:31 +0100 Subject: [PATCH 17/56] #143: Set version to 1.6.0 --- release_appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_appveyor.yml b/release_appveyor.yml index 1e430cf..3f3e1c1 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,4 +1,4 @@ -version: 1.5.3.{build} +version: 1.6.0.{build} image: Visual Studio 2019 branches: only: From 702d7501e52cba9d9fe69a116b5b4d7236fe6a95 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Fri, 6 Mar 2020 23:03:59 +0100 Subject: [PATCH 18/56] Use scoped NuGet-API-Key --- release_appveyor.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/release_appveyor.yml b/release_appveyor.yml index 3f3e1c1..62fac2d 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -27,9 +27,10 @@ artifacts: - path: SQLite.CodeFirst\bin\Release\*.nupkg name: NuPkg deploy: +# Encrypt with https://ci.appveyor.com/tools/encrypt - provider: NuGet api_key: - secure: QmbFnerlfTAFUZpnaPgVDywMH4fF8rVakefmqvhu3qm9SpuDlLGB9S4HwtdE3Nep + secure: wKCSsG3JbuHyNmEL6JagQlGexspQI4W3QTXi0QIWVJKOr4Y0S7j/jUEOJoUCzORK on: branch: master - provider: GitHub From 6b772fec04d34c2ff2d6a68032c5a67b18ac6274 Mon Sep 17 00:00:00 2001 From: Axel Heer Date: Sat, 25 Apr 2020 17:31:15 +0200 Subject: [PATCH 19/56] #143: Add code-based configuration --- .../Configuration.cs | 28 +++++++++++++++++++ SQLite.CodeFirst.NetCore.Console/Program.cs | 4 +-- .../SQLite.CodeFirst.NetCore.Console.csproj | 3 +- 3 files changed, 32 insertions(+), 3 deletions(-) create mode 100644 SQLite.CodeFirst.NetCore.Console/Configuration.cs diff --git a/SQLite.CodeFirst.NetCore.Console/Configuration.cs b/SQLite.CodeFirst.NetCore.Console/Configuration.cs new file mode 100644 index 0000000..845f483 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/Configuration.cs @@ -0,0 +1,28 @@ +using System.Data.Common; +using System.Data.Entity; +using System.Data.Entity.Core.Common; +using System.Data.Entity.Infrastructure; +using System.Data.SQLite; +using System.Data.SQLite.EF6; + +namespace SQLite.CodeFirst.NetCore.Console +{ + public class Configuration : DbConfiguration, IDbConnectionFactory + { + public Configuration() + { + SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); + SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance); + + var providerServices = (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)); + + SetProviderServices("System.Data.SQLite", providerServices); + SetProviderServices("System.Data.SQLite.EF6", providerServices); + + SetDefaultConnectionFactory(this); + } + + public DbConnection CreateConnection(string connectionString) + => new SQLiteConnection(connectionString); + } +} diff --git a/SQLite.CodeFirst.NetCore.Console/Program.cs b/SQLite.CodeFirst.NetCore.Console/Program.cs index cc622cd..3bd2b42 100644 --- a/SQLite.CodeFirst.NetCore.Console/Program.cs +++ b/SQLite.CodeFirst.NetCore.Console/Program.cs @@ -38,7 +38,7 @@ private static void StartDemoUseFile() System.Console.WriteLine("Starting Demo Application (File)"); System.Console.WriteLine(string.Empty); - using (var context = new FootballDbContext("footballDb")) + using (var context = new FootballDbContext(@"data source=.\db\footballDb\footballDb.sqlite;foreign keys=true")) { CreateAndSeedDatabase(context); DisplaySeededData(context); @@ -144,4 +144,4 @@ private static void PressEnterToExit() System.Console.ReadLine(); } } -} \ No newline at end of file +} diff --git a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj index d09eb1b..37489d0 100644 --- a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj +++ b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj @@ -6,7 +6,8 @@ - + + From 4c5ad2a4803d37f37ed6f7183cecebb54424a0af Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 2 May 2020 09:52:32 +0200 Subject: [PATCH 20/56] #143: Update readme --- README.md | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/README.md b/README.md index bbe4c73..094a3a0 100644 --- a/README.md +++ b/README.md @@ -119,6 +119,34 @@ public class MyContext : DbContext } ``` +### .NET Core example + +Add the following package references. +```xml + + +``` + +Add the following class. +```csharp +public Configuration() +{ + SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); + SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance); + + var providerServices = (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)); + + SetProviderServices("System.Data.SQLite", providerServices); + SetProviderServices("System.Data.SQLite.EF6", providerServices); + + SetDefaultConnectionFactory(this); +} + +public DbConnection CreateConnection(string connectionString) + => new SQLiteConnection(connectionString); +} +``` + ## Structure The code is written in an extensible way. From f21bb452ef13f3cde6ee1e0f051e8bc49ee19671 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 2 May 2020 09:58:00 +0200 Subject: [PATCH 21/56] Code cleanup --- .../Entity/FooCompositeKey.cs | 28 +++++++++---------- .../Entity/FooRelationshipA.cs | 20 ++++++------- .../Entity/FooRelationshipB.cs | 20 ++++++------- SQLite.CodeFirst.Console/Entity/IEntity.cs | 2 +- .../Entity/FooCompositeKey.cs | 28 +++++++++---------- .../Entity/FooRelationshipA.cs | 20 ++++++------- .../Entity/FooRelationshipB.cs | 20 ++++++------- .../Entity/IEntity.cs | 2 +- 8 files changed, 70 insertions(+), 70 deletions(-) diff --git a/SQLite.CodeFirst.Console/Entity/FooCompositeKey.cs b/SQLite.CodeFirst.Console/Entity/FooCompositeKey.cs index 76c4ec4..2301500 100644 --- a/SQLite.CodeFirst.Console/Entity/FooCompositeKey.cs +++ b/SQLite.CodeFirst.Console/Entity/FooCompositeKey.cs @@ -4,22 +4,22 @@ namespace SQLite.CodeFirst.Console.Entity { - /// - /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 - /// - public class FooCompositeKey - { - [Key, Column(Order = 1)] - public int Id { get; set; } + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooCompositeKey + { + [Key, Column(Order = 1)] + public int Id { get; set; } - [Key, Column(Order = 2), StringLength(20)] - public string Version { get; set; } + [Key, Column(Order = 2), StringLength(20)] + public string Version { get; set; } - [StringLength(255)] - public string Name { get; set; } + [StringLength(255)] + public string Name { get; set; } - public virtual ICollection FooeyACollection { get; set; } + public virtual ICollection FooeyACollection { get; set; } - public virtual ICollection FooeyBCollection { get; set; } - } + public virtual ICollection FooeyBCollection { get; set; } + } } \ No newline at end of file diff --git a/SQLite.CodeFirst.Console/Entity/FooRelationshipA.cs b/SQLite.CodeFirst.Console/Entity/FooRelationshipA.cs index 09ec0cb..38baaf2 100644 --- a/SQLite.CodeFirst.Console/Entity/FooRelationshipA.cs +++ b/SQLite.CodeFirst.Console/Entity/FooRelationshipA.cs @@ -3,16 +3,16 @@ namespace SQLite.CodeFirst.Console.Entity { - /// - /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 - /// - public class FooRelationshipA - { - public int Id { get; set; } + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooRelationshipA + { + public int Id { get; set; } - [StringLength(255)] - public string Name { get; set; } + [StringLength(255)] + public string Name { get; set; } - public virtual ICollection Fooey { get; set; } - } + public virtual ICollection Fooey { get; set; } + } } \ No newline at end of file diff --git a/SQLite.CodeFirst.Console/Entity/FooRelationshipB.cs b/SQLite.CodeFirst.Console/Entity/FooRelationshipB.cs index 907dcdb..271d8f8 100644 --- a/SQLite.CodeFirst.Console/Entity/FooRelationshipB.cs +++ b/SQLite.CodeFirst.Console/Entity/FooRelationshipB.cs @@ -3,16 +3,16 @@ namespace SQLite.CodeFirst.Console.Entity { - /// - /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 - /// - public class FooRelationshipB - { - public int Id { get; set; } + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooRelationshipB + { + public int Id { get; set; } - [StringLength(255)] - public string Name { get; set; } + [StringLength(255)] + public string Name { get; set; } - public virtual ICollection Fooey { get; set; } - } + public virtual ICollection Fooey { get; set; } + } } \ No newline at end of file diff --git a/SQLite.CodeFirst.Console/Entity/IEntity.cs b/SQLite.CodeFirst.Console/Entity/IEntity.cs index e88d169..17afb3b 100644 --- a/SQLite.CodeFirst.Console/Entity/IEntity.cs +++ b/SQLite.CodeFirst.Console/Entity/IEntity.cs @@ -1,6 +1,6 @@ namespace SQLite.CodeFirst.Console.Entity { - interface IEntity + public interface IEntity { int Id { get; set; } } diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs index 4020e52..b4bb2d6 100644 --- a/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooCompositeKey.cs @@ -4,22 +4,22 @@ namespace SQLite.CodeFirst.NetCore.Console.Entity { - /// - /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 - /// - public class FooCompositeKey - { - [Key, Column(Order = 1)] - public int Id { get; set; } + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooCompositeKey + { + [Key, Column(Order = 1)] + public int Id { get; set; } - [Key, Column(Order = 2), StringLength(20)] - public string Version { get; set; } + [Key, Column(Order = 2), StringLength(20)] + public string Version { get; set; } - [StringLength(255)] - public string Name { get; set; } + [StringLength(255)] + public string Name { get; set; } - public virtual ICollection FooeyACollection { get; set; } + public virtual ICollection FooeyACollection { get; set; } - public virtual ICollection FooeyBCollection { get; set; } - } + public virtual ICollection FooeyBCollection { get; set; } + } } \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs index 135b3bd..f733cd7 100644 --- a/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipA.cs @@ -3,16 +3,16 @@ namespace SQLite.CodeFirst.NetCore.Console.Entity { - /// - /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 - /// - public class FooRelationshipA - { - public int Id { get; set; } + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooRelationshipA + { + public int Id { get; set; } - [StringLength(255)] - public string Name { get; set; } + [StringLength(255)] + public string Name { get; set; } - public virtual ICollection Fooey { get; set; } - } + public virtual ICollection Fooey { get; set; } + } } \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs index 4997660..3b75f68 100644 --- a/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs +++ b/SQLite.CodeFirst.NetCore.Console/Entity/FooRelationshipB.cs @@ -3,16 +3,16 @@ namespace SQLite.CodeFirst.NetCore.Console.Entity { - /// - /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 - /// - public class FooRelationshipB - { - public int Id { get; set; } + /// + /// See https://github.com/msallin/SQLiteCodeFirst/issues/109 + /// + public class FooRelationshipB + { + public int Id { get; set; } - [StringLength(255)] - public string Name { get; set; } + [StringLength(255)] + public string Name { get; set; } - public virtual ICollection Fooey { get; set; } - } + public virtual ICollection Fooey { get; set; } + } } \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs b/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs index a33e2b6..9a97b92 100644 --- a/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs +++ b/SQLite.CodeFirst.NetCore.Console/Entity/IEntity.cs @@ -1,6 +1,6 @@ namespace SQLite.CodeFirst.NetCore.Console.Entity { - interface IEntity + public interface IEntity { int Id { get; set; } } From cdd45c911a457747c99de01b03fd1a793c21d24b Mon Sep 17 00:00:00 2001 From: "Sallin Marc, I212" Date: Sat, 30 Jan 2021 20:13:30 +0100 Subject: [PATCH 22/56] Update dependencies --- .../SQLite.CodeFirst.NetCore.Console.csproj | 6 +++--- SQLite.CodeFirst/SQLite.CodeFirst.csproj | 2 +- release_appveyor.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj index 37489d0..119d9ae 100644 --- a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj +++ b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj @@ -2,12 +2,12 @@ Exe - netcoreapp3.1 + net5.0 - - + + diff --git a/SQLite.CodeFirst/SQLite.CodeFirst.csproj b/SQLite.CodeFirst/SQLite.CodeFirst.csproj index a723f64..954af58 100644 --- a/SQLite.CodeFirst/SQLite.CodeFirst.csproj +++ b/SQLite.CodeFirst/SQLite.CodeFirst.csproj @@ -20,7 +20,7 @@ - + diff --git a/release_appveyor.yml b/release_appveyor.yml index 62fac2d..c1fd9c6 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,4 +1,4 @@ -version: 1.6.0.{build} +version: 1.6.1.{build} image: Visual Studio 2019 branches: only: From b15864abebb35e42fc4900322e501ce4bc0a2f59 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Sat, 20 Mar 2021 12:37:58 +0100 Subject: [PATCH 23/56] Update dependencies --- README.md | 1 + SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj | 2 +- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 9 ++++----- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 094a3a0..fe628db 100644 --- a/README.md +++ b/README.md @@ -39,6 +39,7 @@ You can use the SQLite CodeFirst in projects that target the following framework - .NET 4.0 (uses net40) - .NET 4.5-4.8 (uses net45) - .NET Core 3.0-3.1 (uses netstandard2.1) +- .NET 5 (uses netstandard2.1) ## How to use diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 3c1470a..21dfe61 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -10,7 +10,7 @@ ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - + diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 0dacc17..1f25c91 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -14,11 +14,10 @@ pdbonly - - - - - + + + + From 8edfe3625560f0e7aee10cc0977d24c50ee8f171 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 8 Apr 2021 14:33:47 +0200 Subject: [PATCH 24/56] Update dependencies --- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 1f25c91..687c599 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -15,7 +15,7 @@ - + From ed11c32e9bfa61c7073cb3b16bf2daf71549cf9c Mon Sep 17 00:00:00 2001 From: Kizzzy Date: Fri, 23 Apr 2021 15:08:26 +0800 Subject: [PATCH 25/56] #107: escape columnName to avoid reserved keyword conflict --- .../IntegrationTests/SqlGenerationTest.cs | 27 ++++++++++--------- .../Statement/ColumnStatementTest.cs | 4 +-- .../Statement/ForeignKeyStatementTest.cs | 10 +++---- .../Statement/PrimaryKeyStatementTest.cs | 4 +-- .../Builder/NameCreators/ColumnNameCreator.cs | 12 +++++++++ .../Internal/Statement/ColumnStatement.cs | 5 ++-- .../Statement/CompositePrimaryKeyStatement.cs | 7 ++--- .../Internal/Statement/ForeignKeyStatement.cs | 10 +++---- 8 files changed, 47 insertions(+), 32 deletions(-) create mode 100644 SQLite.CodeFirst/Internal/Builder/NameCreators/ColumnNameCreator.cs diff --git a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs index 6db4301..6be0a61 100644 --- a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs +++ b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs @@ -1,5 +1,4 @@ -using System; -using System.Data.Common; +using System.Data.Common; using System.Data.Entity; using System.Data.Entity.Infrastructure; using System.Data.SQLite; @@ -14,18 +13,19 @@ namespace SQLite.CodeFirst.Test.IntegrationTests public class SqlGenerationTest { private const string ReferenceSql = - @"CREATE TABLE ""MyTable"" ([Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Name] nvarchar NOT NULL, FOREIGN KEY (Id) REFERENCES ""Coaches""(Id)); + @" +CREATE TABLE ""MyTable"" ([Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Name] nvarchar NOT NULL, FOREIGN KEY ([Id]) REFERENCES ""Coaches""([Id])); CREATE TABLE ""Coaches"" ([Id] INTEGER PRIMARY KEY, [FirstName] nvarchar (50) COLLATE NOCASE, [LastName] nvarchar (50), [Street] nvarchar (100), [City] nvarchar NOT NULL, [CreatedUtc] datetime NOT NULL DEFAULT (DATETIME('now'))); -CREATE TABLE ""TeamPlayer"" ([Id] INTEGER PRIMARY KEY, [Number] int NOT NULL, [TeamId] int NOT NULL, [FirstName] nvarchar (50) COLLATE NOCASE, [LastName] nvarchar (50), [Street] nvarchar (100), [City] nvarchar NOT NULL, [CreatedUtc] datetime NOT NULL DEFAULT (DATETIME('now')), [Mentor_Id] int, FOREIGN KEY (Mentor_Id) REFERENCES ""TeamPlayer""(Id), FOREIGN KEY (TeamId) REFERENCES ""MyTable""(Id) ON DELETE CASCADE); -CREATE TABLE ""Stadions"" ([Name] nvarchar (128) NOT NULL, [Street] nvarchar (128) NOT NULL, [City] nvarchar (128) NOT NULL, [Order] int NOT NULL, [Team_Id] int NOT NULL, PRIMARY KEY(Name, Street, City), FOREIGN KEY (Team_Id) REFERENCES ""MyTable""(Id) ON DELETE CASCADE); -CREATE TABLE ""Foos"" ([FooId] INTEGER PRIMARY KEY, [Name] nvarchar, [FooSelf1Id] int, [FooSelf2Id] int, [FooSelf3Id] int, FOREIGN KEY (FooSelf1Id) REFERENCES ""Foos""(FooId), FOREIGN KEY (FooSelf2Id) REFERENCES ""Foos""(FooId), FOREIGN KEY (FooSelf3Id) REFERENCES ""Foos""(FooId)); -CREATE TABLE ""FooSelves"" ([FooSelfId] INTEGER PRIMARY KEY, [FooId] int NOT NULL, [Number] int NOT NULL, FOREIGN KEY (FooId) REFERENCES ""Foos""(FooId) ON DELETE CASCADE); -CREATE TABLE ""FooSteps"" ([FooStepId] INTEGER PRIMARY KEY, [FooId] int NOT NULL, [Number] int NOT NULL, FOREIGN KEY (FooId) REFERENCES ""Foos""(FooId) ON DELETE CASCADE); -CREATE TABLE ""FooCompositeKeys"" ([Id] int NOT NULL, [Version] nvarchar (20) NOT NULL, [Name] nvarchar (255), PRIMARY KEY(Id, Version)); +CREATE TABLE ""TeamPlayer"" ([Id] INTEGER PRIMARY KEY, [Number] int NOT NULL, [TeamId] int NOT NULL, [FirstName] nvarchar (50) COLLATE NOCASE, [LastName] nvarchar (50), [Street] nvarchar (100), [City] nvarchar NOT NULL, [CreatedUtc] datetime NOT NULL DEFAULT (DATETIME('now')), [Mentor_Id] int, FOREIGN KEY ([Mentor_Id]) REFERENCES ""TeamPlayer""([Id]), FOREIGN KEY ([TeamId]) REFERENCES ""MyTable""([Id]) ON DELETE CASCADE); +CREATE TABLE ""Stadions"" ([Name] nvarchar (128) NOT NULL, [Street] nvarchar (128) NOT NULL, [City] nvarchar (128) NOT NULL, [Order] int NOT NULL, [Team_Id] int NOT NULL, PRIMARY KEY([Name], [Street], [City]), FOREIGN KEY ([Team_Id]) REFERENCES ""MyTable""([Id]) ON DELETE CASCADE); +CREATE TABLE ""Foos"" ([FooId] INTEGER PRIMARY KEY, [Name] nvarchar, [FooSelf1Id] int, [FooSelf2Id] int, [FooSelf3Id] int, FOREIGN KEY ([FooSelf1Id]) REFERENCES ""Foos""([FooId]), FOREIGN KEY ([FooSelf2Id]) REFERENCES ""Foos""([FooId]), FOREIGN KEY ([FooSelf3Id]) REFERENCES ""Foos""([FooId])); +CREATE TABLE ""FooSelves"" ([FooSelfId] INTEGER PRIMARY KEY, [FooId] int NOT NULL, [Number] int NOT NULL, FOREIGN KEY ([FooId]) REFERENCES ""Foos""([FooId]) ON DELETE CASCADE); +CREATE TABLE ""FooSteps"" ([FooStepId] INTEGER PRIMARY KEY, [FooId] int NOT NULL, [Number] int NOT NULL, FOREIGN KEY ([FooId]) REFERENCES ""Foos""([FooId]) ON DELETE CASCADE); +CREATE TABLE ""FooCompositeKeys"" ([Id] int NOT NULL, [Version] nvarchar (20) NOT NULL, [Name] nvarchar (255), PRIMARY KEY([Id], [Version])); CREATE TABLE ""FooRelationshipAs"" ([Id] INTEGER PRIMARY KEY, [Name] nvarchar (255)); CREATE TABLE ""FooRelationshipBs"" ([Id] INTEGER PRIMARY KEY, [Name] nvarchar (255)); -CREATE TABLE ""FooRelationshipAFooCompositeKeys"" ([FooRelationshipA_Id] int NOT NULL, [FooCompositeKey_Id] int NOT NULL, [FooCompositeKey_Version] nvarchar (20) NOT NULL, PRIMARY KEY(FooRelationshipA_Id, FooCompositeKey_Id, FooCompositeKey_Version), FOREIGN KEY (FooRelationshipA_Id) REFERENCES ""FooRelationshipAs""(Id) ON DELETE CASCADE, FOREIGN KEY (FooCompositeKey_Id, FooCompositeKey_Version) REFERENCES ""FooCompositeKeys""(Id, Version) ON DELETE CASCADE); -CREATE TABLE ""FooRelationshipBFooCompositeKeys"" ([FooRelationshipB_Id] int NOT NULL, [FooCompositeKey_Id] int NOT NULL, [FooCompositeKey_Version] nvarchar (20) NOT NULL, PRIMARY KEY(FooRelationshipB_Id, FooCompositeKey_Id, FooCompositeKey_Version), FOREIGN KEY (FooRelationshipB_Id) REFERENCES ""FooRelationshipBs""(Id) ON DELETE CASCADE, FOREIGN KEY (FooCompositeKey_Id, FooCompositeKey_Version) REFERENCES ""FooCompositeKeys""(Id, Version) ON DELETE CASCADE); +CREATE TABLE ""FooRelationshipAFooCompositeKeys"" ([FooRelationshipA_Id] int NOT NULL, [FooCompositeKey_Id] int NOT NULL, [FooCompositeKey_Version] nvarchar (20) NOT NULL, PRIMARY KEY([FooRelationshipA_Id], [FooCompositeKey_Id], [FooCompositeKey_Version]), FOREIGN KEY ([FooRelationshipA_Id]) REFERENCES ""FooRelationshipAs""([Id]) ON DELETE CASCADE, FOREIGN KEY ([FooCompositeKey_Id], [FooCompositeKey_Version]) REFERENCES ""FooCompositeKeys""([Id], [Version]) ON DELETE CASCADE); +CREATE TABLE ""FooRelationshipBFooCompositeKeys"" ([FooRelationshipB_Id] int NOT NULL, [FooCompositeKey_Id] int NOT NULL, [FooCompositeKey_Version] nvarchar (20) NOT NULL, PRIMARY KEY([FooRelationshipB_Id], [FooCompositeKey_Id], [FooCompositeKey_Version]), FOREIGN KEY ([FooRelationshipB_Id]) REFERENCES ""FooRelationshipBs""([Id]) ON DELETE CASCADE, FOREIGN KEY ([FooCompositeKey_Id], [FooCompositeKey_Version]) REFERENCES ""FooCompositeKeys""([Id], [Version]) ON DELETE CASCADE); CREATE INDEX ""IX_MyTable_Id"" ON ""MyTable"" (""Id""); CREATE INDEX ""IX_Team_TeamsName"" ON ""MyTable"" (""Name""); CREATE INDEX ""IX_TeamPlayer_Number"" ON ""TeamPlayer"" (""Number""); @@ -42,12 +42,13 @@ public class SqlGenerationTest CREATE INDEX ""IX_FooRelationshipAFooCompositeKey_FooRelationshipA_Id"" ON ""FooRelationshipAFooCompositeKeys"" (""FooRelationshipA_Id""); CREATE INDEX ""IX_FooRelationshipAFooCompositeKey_FooCompositeKey_Id_FooCompositeKey_Version"" ON ""FooRelationshipAFooCompositeKeys"" (""FooCompositeKey_Id"", ""FooCompositeKey_Version""); CREATE INDEX ""IX_FooRelationshipBFooCompositeKey_FooRelationshipB_Id"" ON ""FooRelationshipBFooCompositeKeys"" (""FooRelationshipB_Id""); -CREATE INDEX ""IX_FooRelationshipBFooCompositeKey_FooCompositeKey_Id_FooCompositeKey_Version"" ON ""FooRelationshipBFooCompositeKeys"" (""FooCompositeKey_Id"", ""FooCompositeKey_Version"");"; +CREATE INDEX ""IX_FooRelationshipBFooCompositeKey_FooCompositeKey_Id_FooCompositeKey_Version"" ON ""FooRelationshipBFooCompositeKeys"" (""FooCompositeKey_Id"", ""FooCompositeKey_Version""); +"; private static string generatedSql; // Does not work on the build server. No clue why. - + [TestMethod] public void SqliteSqlGeneratorTest() { diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs index 4d81d75..9e47dc5 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs @@ -16,9 +16,9 @@ public void CreateStatement() var columnStatement = new ColumnStatement { - ColumnConstraints = columnConstraintsMock.Object, ColumnName = "dummyColumnName", - TypeName = "dummyType" + TypeName = "dummyType", + ColumnConstraints = columnConstraintsMock.Object, }; string output = columnStatement.CreateStatement(); Assert.AreEqual(output, "[dummyColumnName] dummyType dummyColumnConstraint"); diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs index 192a6b7..c3472de 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs @@ -19,7 +19,7 @@ public void CreateStatementOneForeignKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY (dummyForeignKey1) REFERENCES dummyForeignTable(dummForeignPrimaryKey1)"); + Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])"); } [TestMethod] @@ -34,7 +34,7 @@ public void CreateStatementOneForeignKeyCascadeDeleteTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY (dummyForeignKey1) REFERENCES dummyForeignTable(dummForeignPrimaryKey1) ON DELETE CASCADE"); + Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE"); } [TestMethod] @@ -49,7 +49,7 @@ public void CreateStatementTwoForeignKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY (dummyForeignKey1, dummyForeignKey2) REFERENCES dummyForeignTable(dummForeignPrimaryKey1)"); + Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])"); } [TestMethod] @@ -64,7 +64,7 @@ public void CreateStatementTwoForeignKeyTwoPrimaryKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY (dummyForeignKey1, dummyForeignKey2) REFERENCES dummyForeignTable(dummForeignPrimaryKey1, dummForeignPrimaryKey2)"); + Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])"); } [TestMethod] @@ -79,7 +79,7 @@ public void CreateStatementOneForeignKeyTwoPrimaryKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY (dummyForeignKey1) REFERENCES dummyForeignTable(dummForeignPrimaryKey1, dummForeignPrimaryKey2)"); + Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])"); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs index 7ece059..beffd06 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs @@ -14,7 +14,7 @@ public void CreateStatementWithOneKeyTest() var primaryKeyStatement = new CompositePrimaryKeyStatement(new List { keyMember1 }); Assert.AreEqual(primaryKeyStatement.Count, 1); - Assert.AreEqual(primaryKeyStatement.CreateStatement(), "PRIMARY KEY(keyMember1)"); + Assert.AreEqual(primaryKeyStatement.CreateStatement(), "PRIMARY KEY([keyMember1])"); } [TestMethod] @@ -25,7 +25,7 @@ public void CreateStatementWithTwoKeyTest() var primaryKeyStatement = new CompositePrimaryKeyStatement(new List { keyMember1, keyMember2 }); Assert.AreEqual(primaryKeyStatement.Count, 2); - Assert.AreEqual(primaryKeyStatement.CreateStatement(), "PRIMARY KEY(keyMember1, keyMember2)"); + Assert.AreEqual(primaryKeyStatement.CreateStatement(), "PRIMARY KEY([keyMember1], [keyMember2])"); } } } diff --git a/SQLite.CodeFirst/Internal/Builder/NameCreators/ColumnNameCreator.cs b/SQLite.CodeFirst/Internal/Builder/NameCreators/ColumnNameCreator.cs new file mode 100644 index 0000000..c533dfd --- /dev/null +++ b/SQLite.CodeFirst/Internal/Builder/NameCreators/ColumnNameCreator.cs @@ -0,0 +1,12 @@ +using System.Globalization; + +namespace SQLite.CodeFirst.Builder.NameCreators +{ + internal static class ColumnNameCreator + { + public static string EscapeName(string columnName) + { + return string.Format(CultureInfo.InvariantCulture, "[{0}]", columnName); + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst/Internal/Statement/ColumnStatement.cs b/SQLite.CodeFirst/Internal/Statement/ColumnStatement.cs index bf4f91d..d55b091 100644 --- a/SQLite.CodeFirst/Internal/Statement/ColumnStatement.cs +++ b/SQLite.CodeFirst/Internal/Statement/ColumnStatement.cs @@ -1,11 +1,12 @@ using System.Text; +using SQLite.CodeFirst.Builder.NameCreators; using SQLite.CodeFirst.Statement.ColumnConstraint; namespace SQLite.CodeFirst.Statement { internal class ColumnStatement : IStatement { - private const string Template = "[{column-name}] {type-name} {column-constraint}"; + private const string Template = "{column-name} {type-name} {column-constraint}"; public string ColumnName { get; set; } public string TypeName { get; set; } @@ -15,7 +16,7 @@ public string CreateStatement() { var sb = new StringBuilder(Template); - sb.Replace("{column-name}", ColumnName); + sb.Replace("{column-name}", ColumnNameCreator.EscapeName(ColumnName)); sb.Replace("{type-name}", TypeName); sb.Replace("{column-constraint}", ColumnConstraints.CreateStatement()); diff --git a/SQLite.CodeFirst/Internal/Statement/CompositePrimaryKeyStatement.cs b/SQLite.CodeFirst/Internal/Statement/CompositePrimaryKeyStatement.cs index f2d0374..196f305 100644 --- a/SQLite.CodeFirst/Internal/Statement/CompositePrimaryKeyStatement.cs +++ b/SQLite.CodeFirst/Internal/Statement/CompositePrimaryKeyStatement.cs @@ -1,13 +1,14 @@ -using System; +using SQLite.CodeFirst.Builder.NameCreators; +using System; using System.Collections.Generic; using System.Collections.ObjectModel; +using System.Linq; namespace SQLite.CodeFirst.Statement { internal class CompositePrimaryKeyStatement : Collection, IStatement { private const string Template = "PRIMARY KEY({primary-keys})"; - private const string PrimaryKeyColumnNameSeperator = ", "; public CompositePrimaryKeyStatement(IEnumerable keyMembers) { @@ -19,7 +20,7 @@ public CompositePrimaryKeyStatement(IEnumerable keyMembers) public string CreateStatement() { - string primaryKeys = String.Join(PrimaryKeyColumnNameSeperator, this); + string primaryKeys = String.Join(", ", this.Select(c => ColumnNameCreator.EscapeName(c))); return Template.Replace("{primary-keys}", primaryKeys); } } diff --git a/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs b/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs index 19b61b4..58b4974 100644 --- a/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs +++ b/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs @@ -1,4 +1,6 @@ -using System.Collections.Generic; +using SQLite.CodeFirst.Builder.NameCreators; +using System.Collections.Generic; +using System.Linq; using System.Text; namespace SQLite.CodeFirst.Statement @@ -16,11 +18,9 @@ internal class ForeignKeyStatement : IStatement public string CreateStatement() { var sb = new StringBuilder(Template); - - sb.Replace("{foreign-key}", string.Join(", ", ForeignKey)); + sb.Replace("{foreign-key}", string.Join(", ", ForeignKey.Select(c => ColumnNameCreator.EscapeName(c)))); sb.Replace("{referenced-table}", ForeignTable); - sb.Replace("{referenced-id}", string.Join(", ", ForeignPrimaryKey)); - + sb.Replace("{referenced-id}", string.Join(", ", ForeignPrimaryKey.Select(c => ColumnNameCreator.EscapeName(c)))); if (CascadeDelete) { sb.Append(" " + CascadeDeleteStatement); From 732c7a06ed33716657180db03880b0648db954ad Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Fri, 23 Apr 2021 11:45:41 +0200 Subject: [PATCH 26/56] Set version to 1.6.2 --- release_appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_appveyor.yml b/release_appveyor.yml index c1fd9c6..57a1cd6 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,4 +1,4 @@ -version: 1.6.1.{build} +version: 1.6.2.{build} image: Visual Studio 2019 branches: only: From 58b3371ce35a2a9ae69d5564dd7451047f080cb5 Mon Sep 17 00:00:00 2001 From: Magnus Grindal Bakken Date: Thu, 29 Apr 2021 14:13:12 +0200 Subject: [PATCH 27/56] #163 Add support for defining a default collation --- README.md | 1 + .../SqlGenerationDefaultCollationTest.cs | 118 ++++++++++++++++++ .../ColumnStatementCollectionBuilder.cs | 30 +++-- .../Builder/CreateDatabaseStatementBuilder.cs | 6 +- .../Builder/CreateTableStatementBuilder.cs | 6 +- .../Public/Attributes/CollateAttribute.cs | 34 ++--- SQLite.CodeFirst/Public/Collation.cs | 46 +++++++ .../{Attributes => }/CollationFunction.cs | 2 +- ...qliteDropCreateDatabaseWhenModelChanges.cs | 2 +- .../DbInitializers/SqliteInitializerBase.cs | 7 +- .../Public/SqliteDatabaseCreator.cs | 9 +- SQLite.CodeFirst/Public/SqliteSqlGenerator.cs | 9 +- 12 files changed, 226 insertions(+), 44 deletions(-) create mode 100644 SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs create mode 100644 SQLite.CodeFirst/Public/Collation.cs rename SQLite.CodeFirst/Public/{Attributes => }/CollationFunction.cs (95%) diff --git a/README.md b/README.md index fe628db..d3be8f2 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,7 @@ The following features are supported: - Index (Decorate columns with the `Index` attribute. Indices are automatically created for foreign keys by default. To prevent this you can remove the convention `ForeignKeyIndexConvention`) - Unique constraint (Decorate columns with the `UniqueAttribute`, which is part of this library) - Collate constraint (Decorate columns with the `CollateAttribute`, which is part of this library. Use `CollationFunction.Custom` to specify a own collation function.) +- Default collation (pass an instance of Collation as constructor parameter for an initializer to specify a default collation). - SQL default value (Decorate columns with the `SqlDefaultValueAttribute`, which is part of this library) ## Install diff --git a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs new file mode 100644 index 0000000..d6cbd08 --- /dev/null +++ b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs @@ -0,0 +1,118 @@ +using System.Data.Common; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Data.SQLite; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SQLite.CodeFirst.Console; +using SQLite.CodeFirst.Console.Entity; + +namespace SQLite.CodeFirst.Test.IntegrationTests +{ + [TestClass] + public class SqlGenerationDefaultCollationTest + { + private const string ReferenceSql = + @" +CREATE TABLE ""MyTable"" ([Id] INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT, [Name] nvarchar NOT NULL COLLATE custom_collate, FOREIGN KEY ([Id]) REFERENCES ""Coaches""([Id])); +CREATE TABLE ""Coaches"" ([Id] INTEGER PRIMARY KEY, [FirstName] nvarchar (50) COLLATE NOCASE, [LastName] nvarchar (50) COLLATE custom_collate, [Street] nvarchar (100) COLLATE custom_collate, [City] nvarchar NOT NULL COLLATE custom_collate, [CreatedUtc] datetime NOT NULL DEFAULT (DATETIME('now'))); +CREATE TABLE ""TeamPlayer"" ([Id] INTEGER PRIMARY KEY, [Number] int NOT NULL, [TeamId] int NOT NULL, [FirstName] nvarchar (50) COLLATE NOCASE, [LastName] nvarchar (50) COLLATE custom_collate, [Street] nvarchar (100) COLLATE custom_collate, [City] nvarchar NOT NULL COLLATE custom_collate, [CreatedUtc] datetime NOT NULL DEFAULT (DATETIME('now')), [Mentor_Id] int, FOREIGN KEY ([Mentor_Id]) REFERENCES ""TeamPlayer""([Id]), FOREIGN KEY ([TeamId]) REFERENCES ""MyTable""([Id]) ON DELETE CASCADE); +CREATE TABLE ""Stadions"" ([Name] nvarchar (128) NOT NULL COLLATE custom_collate, [Street] nvarchar (128) NOT NULL COLLATE custom_collate, [City] nvarchar (128) NOT NULL COLLATE custom_collate, [Order] int NOT NULL, [Team_Id] int NOT NULL, PRIMARY KEY([Name], [Street], [City]), FOREIGN KEY ([Team_Id]) REFERENCES ""MyTable""([Id]) ON DELETE CASCADE); +CREATE TABLE ""Foos"" ([FooId] INTEGER PRIMARY KEY, [Name] nvarchar COLLATE custom_collate, [FooSelf1Id] int, [FooSelf2Id] int, [FooSelf3Id] int, FOREIGN KEY ([FooSelf1Id]) REFERENCES ""Foos""([FooId]), FOREIGN KEY ([FooSelf2Id]) REFERENCES ""Foos""([FooId]), FOREIGN KEY ([FooSelf3Id]) REFERENCES ""Foos""([FooId])); +CREATE TABLE ""FooSelves"" ([FooSelfId] INTEGER PRIMARY KEY, [FooId] int NOT NULL, [Number] int NOT NULL, FOREIGN KEY ([FooId]) REFERENCES ""Foos""([FooId]) ON DELETE CASCADE); +CREATE TABLE ""FooSteps"" ([FooStepId] INTEGER PRIMARY KEY, [FooId] int NOT NULL, [Number] int NOT NULL, FOREIGN KEY ([FooId]) REFERENCES ""Foos""([FooId]) ON DELETE CASCADE); +CREATE TABLE ""FooCompositeKeys"" ([Id] int NOT NULL, [Version] nvarchar (20) NOT NULL COLLATE custom_collate, [Name] nvarchar (255) COLLATE custom_collate, PRIMARY KEY([Id], [Version])); +CREATE TABLE ""FooRelationshipAs"" ([Id] INTEGER PRIMARY KEY, [Name] nvarchar (255) COLLATE custom_collate); +CREATE TABLE ""FooRelationshipBs"" ([Id] INTEGER PRIMARY KEY, [Name] nvarchar (255) COLLATE custom_collate); +CREATE TABLE ""FooRelationshipAFooCompositeKeys"" ([FooRelationshipA_Id] int NOT NULL, [FooCompositeKey_Id] int NOT NULL, [FooCompositeKey_Version] nvarchar (20) NOT NULL COLLATE custom_collate, PRIMARY KEY([FooRelationshipA_Id], [FooCompositeKey_Id], [FooCompositeKey_Version]), FOREIGN KEY ([FooRelationshipA_Id]) REFERENCES ""FooRelationshipAs""([Id]) ON DELETE CASCADE, FOREIGN KEY ([FooCompositeKey_Id], [FooCompositeKey_Version]) REFERENCES ""FooCompositeKeys""([Id], [Version]) ON DELETE CASCADE); +CREATE TABLE ""FooRelationshipBFooCompositeKeys"" ([FooRelationshipB_Id] int NOT NULL, [FooCompositeKey_Id] int NOT NULL, [FooCompositeKey_Version] nvarchar (20) NOT NULL COLLATE custom_collate, PRIMARY KEY([FooRelationshipB_Id], [FooCompositeKey_Id], [FooCompositeKey_Version]), FOREIGN KEY ([FooRelationshipB_Id]) REFERENCES ""FooRelationshipBs""([Id]) ON DELETE CASCADE, FOREIGN KEY ([FooCompositeKey_Id], [FooCompositeKey_Version]) REFERENCES ""FooCompositeKeys""([Id], [Version]) ON DELETE CASCADE); +CREATE INDEX ""IX_MyTable_Id"" ON ""MyTable"" (""Id""); +CREATE INDEX ""IX_Team_TeamsName"" ON ""MyTable"" (""Name""); +CREATE INDEX ""IX_TeamPlayer_Number"" ON ""TeamPlayer"" (""Number""); +CREATE UNIQUE INDEX ""IX_TeamPlayer_NumberPerTeam"" ON ""TeamPlayer"" (""Number"", ""TeamId""); +CREATE INDEX ""IX_TeamPlayer_Mentor_Id"" ON ""TeamPlayer"" (""Mentor_Id""); +CREATE UNIQUE INDEX ""IX_Stadion_Main"" ON ""Stadions"" (""Street"", ""Name""); +CREATE UNIQUE INDEX ""ReservedKeyWordTest"" ON ""Stadions"" (""Order""); +CREATE INDEX ""IX_Stadion_Team_Id"" ON ""Stadions"" (""Team_Id""); +CREATE INDEX ""IX_Foo_FooSelf1Id"" ON ""Foos"" (""FooSelf1Id""); +CREATE INDEX ""IX_Foo_FooSelf2Id"" ON ""Foos"" (""FooSelf2Id""); +CREATE INDEX ""IX_Foo_FooSelf3Id"" ON ""Foos"" (""FooSelf3Id""); +CREATE INDEX ""IX_FooSelf_FooId"" ON ""FooSelves"" (""FooId""); +CREATE INDEX ""IX_FooStep_FooId"" ON ""FooSteps"" (""FooId""); +CREATE INDEX ""IX_FooRelationshipAFooCompositeKey_FooRelationshipA_Id"" ON ""FooRelationshipAFooCompositeKeys"" (""FooRelationshipA_Id""); +CREATE INDEX ""IX_FooRelationshipAFooCompositeKey_FooCompositeKey_Id_FooCompositeKey_Version"" ON ""FooRelationshipAFooCompositeKeys"" (""FooCompositeKey_Id"", ""FooCompositeKey_Version""); +CREATE INDEX ""IX_FooRelationshipBFooCompositeKey_FooRelationshipB_Id"" ON ""FooRelationshipBFooCompositeKeys"" (""FooRelationshipB_Id""); +CREATE INDEX ""IX_FooRelationshipBFooCompositeKey_FooCompositeKey_Id_FooCompositeKey_Version"" ON ""FooRelationshipBFooCompositeKeys"" (""FooCompositeKey_Id"", ""FooCompositeKey_Version""); +"; + + private static string generatedSql; + + // Does not work on the build server. No clue why. + + [TestMethod] + public void SqliteSqlGeneratorWithDefaultCollationTest() + { + using (DbConnection connection = new SQLiteConnection("FullUri=file::memory:")) + { + // This is important! Else the in memory database will not work. + connection.Open(); + + var defaultCollation = new Collation() { Function = CollationFunction.Custom, CustomFunction = "custom_collate" }; + using (var context = new DummyDbContext(connection, defaultCollation)) + { + // ReSharper disable once UnusedVariable + Player fo = context.Set().FirstOrDefault(); + + Assert.AreEqual(RemoveLineEndings(ReferenceSql), RemoveLineEndings(generatedSql)); + } + } + } + + private static string RemoveLineEndings(string input) + { + string lineSeparator = ((char)0x2028).ToString(); + string paragraphSeparator = ((char)0x2029).ToString(); + return input.Replace("\r\n", string.Empty).Replace("\n", string.Empty).Replace("\r", string.Empty).Replace(lineSeparator, string.Empty).Replace(paragraphSeparator, string.Empty); + } + + private class DummyDbContext : DbContext + { + private readonly Collation defaultCollation; + + public DummyDbContext(DbConnection connection, Collation defaultCollation = null) + : base(connection, false) + { + this.defaultCollation = defaultCollation; + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + // This configuration contains all supported cases. + // So it makes a perfect test to validate whether the + // generated SQL is correct. + ModelConfiguration.Configure(modelBuilder); + var initializer = new AssertInitializer(modelBuilder, defaultCollation); + Database.SetInitializer(initializer); + } + + private class AssertInitializer : SqliteInitializerBase + { + private readonly Collation defaultCollation; + + public AssertInitializer(DbModelBuilder modelBuilder, Collation defaultCollation) + : base(modelBuilder) + { + this.defaultCollation = defaultCollation; + } + + public override void InitializeDatabase(DummyDbContext context) + { + DbModel model = ModelBuilder.Build(context.Database.Connection); + var sqliteSqlGenerator = new SqliteSqlGenerator(defaultCollation); + generatedSql = sqliteSqlGenerator.Generate(model.StoreModel); + base.InitializeDatabase(context); + } + } + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst/Internal/Builder/ColumnStatementCollectionBuilder.cs b/SQLite.CodeFirst/Internal/Builder/ColumnStatementCollectionBuilder.cs index 93043c2..3fba1bb 100644 --- a/SQLite.CodeFirst/Internal/Builder/ColumnStatementCollectionBuilder.cs +++ b/SQLite.CodeFirst/Internal/Builder/ColumnStatementCollectionBuilder.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Data.Entity.Core.Metadata.Edm; using System.Linq; using SQLite.CodeFirst.Extensions; @@ -11,11 +12,13 @@ internal class ColumnStatementCollectionBuilder : IStatementBuilder properties; private readonly IEnumerable keyMembers; + private readonly Collation defaultCollation; - public ColumnStatementCollectionBuilder(IEnumerable properties, IEnumerable keyMembers) + public ColumnStatementCollectionBuilder(IEnumerable properties, IEnumerable keyMembers, Collation defaultCollation) { this.properties = properties; this.keyMembers = keyMembers; + this.defaultCollation = defaultCollation; } public ColumnStatementCollection BuildStatement() @@ -39,7 +42,7 @@ private IEnumerable CreateColumnStatements() AdjustDatatypeForAutogenerationIfNecessary(property, columnStatement); AddNullConstraintIfNecessary(property, columnStatement); AddUniqueConstraintIfNecessary(property, columnStatement); - AddCollationConstraintIfNecessary(property, columnStatement); + AddCollationConstraintIfNecessary(property, columnStatement, defaultCollation); AddPrimaryKeyConstraintAndAdjustTypeIfNecessary(property, columnStatement); AddDefaultValueConstraintIfNecessary(property, columnStatement); @@ -73,12 +76,25 @@ private static void AddNullConstraintIfNecessary(EdmProperty property, ColumnSta } } - private static void AddCollationConstraintIfNecessary(EdmProperty property, ColumnStatement columnStatement) + private static void AddCollationConstraintIfNecessary(EdmProperty property, ColumnStatement columnStatement, Collation defaultCollation) { - var value = property.GetCustomAnnotation(); - if (value != null) + var collateAttribute = property.GetCustomAnnotation(); + if (property.PrimitiveType.PrimitiveTypeKind == PrimitiveTypeKind.String) + { + // The column is a string type. Check if we have an explicit or default collation. + // If we have both, the explicitly chosen collation takes precedence. + var value = collateAttribute == null ? defaultCollation : collateAttribute.Collation; + if (value != null) + { + columnStatement.ColumnConstraints.Add(new CollateConstraint { CollationFunction = value.Function, CustomCollationFunction = value.CustomFunction }); + } + } + else if (collateAttribute != null) { - columnStatement.ColumnConstraints.Add(new CollateConstraint { CollationFunction = value.Collation, CustomCollationFunction = value.Function }); + // Only string columns can be explicitly decorated with CollateAttribute. + var name = $"{property.DeclaringType.Name}.{property.Name}"; + var errorMessage = $"CollateAttribute cannot be used on non-string property: {name} (underlying type is {property.PrimitiveType.PrimitiveTypeKind})"; + throw new InvalidOperationException(errorMessage); } } diff --git a/SQLite.CodeFirst/Internal/Builder/CreateDatabaseStatementBuilder.cs b/SQLite.CodeFirst/Internal/Builder/CreateDatabaseStatementBuilder.cs index 65862a2..ea87cca 100644 --- a/SQLite.CodeFirst/Internal/Builder/CreateDatabaseStatementBuilder.cs +++ b/SQLite.CodeFirst/Internal/Builder/CreateDatabaseStatementBuilder.cs @@ -9,10 +9,12 @@ namespace SQLite.CodeFirst.Builder internal class CreateDatabaseStatementBuilder : IStatementBuilder { private readonly EdmModel edmModel; + private readonly Collation defaultCollation; - public CreateDatabaseStatementBuilder(EdmModel edmModel) + public CreateDatabaseStatementBuilder(EdmModel edmModel, Collation defaultCollation) { this.edmModel = edmModel; + this.defaultCollation = defaultCollation; } public CreateDatabaseStatement BuildStatement() @@ -30,7 +32,7 @@ private IEnumerable GetCreateTableStatements() foreach (var entitySet in edmModel.Container.EntitySets) { - var tableStatementBuilder = new CreateTableStatementBuilder(entitySet, associationTypeContainer); + var tableStatementBuilder = new CreateTableStatementBuilder(entitySet, associationTypeContainer, defaultCollation); yield return tableStatementBuilder.BuildStatement(); } } diff --git a/SQLite.CodeFirst/Internal/Builder/CreateTableStatementBuilder.cs b/SQLite.CodeFirst/Internal/Builder/CreateTableStatementBuilder.cs index b86f701..ac3198b 100644 --- a/SQLite.CodeFirst/Internal/Builder/CreateTableStatementBuilder.cs +++ b/SQLite.CodeFirst/Internal/Builder/CreateTableStatementBuilder.cs @@ -12,11 +12,13 @@ internal class CreateTableStatementBuilder : IStatementBuilder(); diff --git a/SQLite.CodeFirst/Public/Attributes/CollateAttribute.cs b/SQLite.CodeFirst/Public/Attributes/CollateAttribute.cs index 2dfc272..636965a 100644 --- a/SQLite.CodeFirst/Public/Attributes/CollateAttribute.cs +++ b/SQLite.CodeFirst/Public/Attributes/CollateAttribute.cs @@ -12,39 +12,19 @@ public sealed class CollateAttribute : Attribute { public CollateAttribute() { - Collation = CollationFunction.None; + Collation = new Collation(); } - public CollateAttribute(CollationFunction collation) + public CollateAttribute(CollationFunction function) { - if (collation == CollationFunction.Custom) - { - throw new ArgumentException("If the collation is set to CollationFunction.Custom a function must be specified.", nameof(collation)); - } - - Collation = collation; + Collation = new Collation(function); } - public CollateAttribute(CollationFunction collation, string function) - { - if (collation != CollationFunction.Custom && !string.IsNullOrEmpty(function)) - { - throw new ArgumentException("If the collation is not set to CollationFunction.Custom a function must not be specified.", nameof(function)); - } - - if (collation == CollationFunction.Custom && string.IsNullOrEmpty(function)) - { - throw new ArgumentException("If the collation is set to CollationFunction.Custom a function must be specified.", nameof(function)); - } - Collation = collation; - Function = function; + public CollateAttribute(CollationFunction function, string customFunction) + { + Collation = new Collation(function, customFunction); } - public CollationFunction Collation { get; } - - /// - /// The name of the custom collating function to use (CollationFunction.Custom). - /// - public string Function { get; } + public Collation Collation { get; } } } \ No newline at end of file diff --git a/SQLite.CodeFirst/Public/Collation.cs b/SQLite.CodeFirst/Public/Collation.cs new file mode 100644 index 0000000..0695e73 --- /dev/null +++ b/SQLite.CodeFirst/Public/Collation.cs @@ -0,0 +1,46 @@ +using System; + +namespace SQLite.CodeFirst +{ + /// + /// This class can be used to specify the default collation for the database. Explicit Collate attributes will take precendence. + /// When SQLite compares two strings, it uses a collating sequence or collating function (two words for the same thing) + /// to determine which string is greater or if the two strings are equal. SQLite has three built-in collating functions (see ). + /// Set to and specify the name using the function parameter. + /// + public class Collation + { + public Collation() + : this(CollationFunction.None) + { + } + + public Collation(CollationFunction function) + : this(function, null) + { + } + + public Collation(CollationFunction function, string customFunction) + { + if (function != CollationFunction.Custom && !string.IsNullOrEmpty(customFunction)) + { + throw new ArgumentException("If the collation is not set to CollationFunction.Custom a function must not be specified.", nameof(function)); + } + + if (function == CollationFunction.Custom && string.IsNullOrEmpty(customFunction)) + { + throw new ArgumentException("If the collation is set to CollationFunction.Custom a function must be specified.", nameof(function)); + } + + CustomFunction = customFunction; + Function = function; + } + + public CollationFunction Function { get; set; } + + /// + /// The name of the custom collating function to use (CollationFunction.Custom). + /// + public string CustomFunction { get; set; } + } +} diff --git a/SQLite.CodeFirst/Public/Attributes/CollationFunction.cs b/SQLite.CodeFirst/Public/CollationFunction.cs similarity index 95% rename from SQLite.CodeFirst/Public/Attributes/CollationFunction.cs rename to SQLite.CodeFirst/Public/CollationFunction.cs index 1bb7f30..6bd054d 100644 --- a/SQLite.CodeFirst/Public/Attributes/CollationFunction.cs +++ b/SQLite.CodeFirst/Public/CollationFunction.cs @@ -2,7 +2,7 @@ { /// /// The collation function to use for this column. - /// Is used together with the . + /// Is used together with the , and when setting a default collation for the database. /// public enum CollationFunction { diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index d83c3a9..f8029fc 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -172,7 +172,7 @@ private string GetHashFromModel(DbConnection connection) private string GetSqlFromModel(DbConnection connection) { var model = ModelBuilder.Build(connection); - var sqliteSqlGenerator = new SqliteSqlGenerator(); + var sqliteSqlGenerator = new SqliteSqlGenerator(DefaultCollation); return sqliteSqlGenerator.Generate(model.StoreModel); } } diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs index a84cdf8..1309b1f 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs @@ -24,9 +24,10 @@ namespace SQLite.CodeFirst public abstract class SqliteInitializerBase : IDatabaseInitializer where TContext : DbContext { - protected SqliteInitializerBase(DbModelBuilder modelBuilder) + protected SqliteInitializerBase(DbModelBuilder modelBuilder, Collation defaultCollation = null) { ModelBuilder = modelBuilder ?? throw new ArgumentNullException(nameof(modelBuilder)); + DefaultCollation = defaultCollation; // This convention will crash the SQLite Provider before "InitializeDatabase" gets called. // See https://github.com/msallin/SQLiteCodeFirst/issues/7 for details. @@ -55,6 +56,8 @@ protected SqliteInitializerBase(DbModelBuilder modelBuilder) } } + public Collation DefaultCollation { get; } + protected DbModelBuilder ModelBuilder { get; } /// @@ -71,7 +74,7 @@ public virtual void InitializeDatabase(TContext context) string dbFile = GetDatabasePathFromContext(context); InMemoryAwareFile.CreateDirectory(dbFile); - var sqliteDatabaseCreator = new SqliteDatabaseCreator(); + var sqliteDatabaseCreator = new SqliteDatabaseCreator(DefaultCollation); sqliteDatabaseCreator.Create(context.Database, model); Seed(context); diff --git a/SQLite.CodeFirst/Public/SqliteDatabaseCreator.cs b/SQLite.CodeFirst/Public/SqliteDatabaseCreator.cs index 4fd325e..0626c24 100644 --- a/SQLite.CodeFirst/Public/SqliteDatabaseCreator.cs +++ b/SQLite.CodeFirst/Public/SqliteDatabaseCreator.cs @@ -16,6 +16,13 @@ namespace SQLite.CodeFirst /// public class SqliteDatabaseCreator : IDatabaseCreator { + public SqliteDatabaseCreator(Collation defaultCollation = null) + { + DefaultCollation = defaultCollation; + } + + public Collation DefaultCollation { get; } + /// /// Creates the SQLite-Database. /// @@ -24,7 +31,7 @@ public void Create(Database db, DbModel model) if (db == null) throw new ArgumentNullException("db"); if (model == null) throw new ArgumentNullException("model"); - var sqliteSqlGenerator = new SqliteSqlGenerator(); + var sqliteSqlGenerator = new SqliteSqlGenerator(DefaultCollation); string sql = sqliteSqlGenerator.Generate(model.StoreModel); Debug.Write(sql); db.ExecuteSqlCommand(TransactionalBehavior.EnsureTransaction, sql); diff --git a/SQLite.CodeFirst/Public/SqliteSqlGenerator.cs b/SQLite.CodeFirst/Public/SqliteSqlGenerator.cs index d0f248a..944115e 100644 --- a/SQLite.CodeFirst/Public/SqliteSqlGenerator.cs +++ b/SQLite.CodeFirst/Public/SqliteSqlGenerator.cs @@ -9,12 +9,19 @@ namespace SQLite.CodeFirst /// public class SqliteSqlGenerator : ISqlGenerator { + public SqliteSqlGenerator(Collation defaultCollation = null) + { + DefaultCollation = defaultCollation; + } + + public Collation DefaultCollation { get; } + /// /// Generates the SQL statement, based on the . /// public string Generate(EdmModel storeModel) { - IStatementBuilder statementBuilder = new CreateDatabaseStatementBuilder(storeModel); + IStatementBuilder statementBuilder = new CreateDatabaseStatementBuilder(storeModel, DefaultCollation); IStatement statement = statementBuilder.BuildStatement(); return statement.CreateStatement(); } From b45919020f120c0303420aa1be13b7d489175855 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Mon, 10 May 2021 15:38:48 +0200 Subject: [PATCH 28/56] Set version to 1.7.0 --- release_appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_appveyor.yml b/release_appveyor.yml index 57a1cd6..66051fd 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,4 +1,4 @@ -version: 1.6.2.{build} +version: 1.7.0.{build} image: Visual Studio 2019 branches: only: From 4cf7bfb26b1d02a364dc22160a25ee10f01bf6e9 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Mon, 10 May 2021 15:45:39 +0200 Subject: [PATCH 29/56] replace expired NuGet API key --- release_appveyor.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_appveyor.yml b/release_appveyor.yml index 66051fd..0945e76 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -30,7 +30,7 @@ deploy: # Encrypt with https://ci.appveyor.com/tools/encrypt - provider: NuGet api_key: - secure: wKCSsG3JbuHyNmEL6JagQlGexspQI4W3QTXi0QIWVJKOr4Y0S7j/jUEOJoUCzORK + secure: /mFKbp4C8bazwSgH5C6JakY8dZEffGRekipyvAUCkYJ+sfQhtsLDrKGek1oTrbAx on: branch: master - provider: GitHub From 582575748677f1166e04336f59b53dad26949e72 Mon Sep 17 00:00:00 2001 From: Micah Date: Thu, 1 Jul 2021 09:32:07 -0500 Subject: [PATCH 30/56] Updated README.md with more .NET Core specifics --- README.md | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/README.md b/README.md index d3be8f2..2fbfd3e 100644 --- a/README.md +++ b/README.md @@ -131,24 +131,34 @@ Add the following package references. Add the following class. ```csharp -public Configuration() -{ - SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); - SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance); +public class MyConfiguration : DbConfiguration, IDbConnectionFactory { + public MyConfiguration() + { + SetProviderFactory("System.Data.SQLite", SQLiteFactory.Instance); + SetProviderFactory("System.Data.SQLite.EF6", SQLiteProviderFactory.Instance); - var providerServices = (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)); + var providerServices = (DbProviderServices)SQLiteProviderFactory.Instance.GetService(typeof(DbProviderServices)); - SetProviderServices("System.Data.SQLite", providerServices); - SetProviderServices("System.Data.SQLite.EF6", providerServices); + SetProviderServices("System.Data.SQLite", providerServices); + SetProviderServices("System.Data.SQLite.EF6", providerServices); - SetDefaultConnectionFactory(this); -} + SetDefaultConnectionFactory(this); + } -public DbConnection CreateConnection(string connectionString) - => new SQLiteConnection(connectionString); + public DbConnection CreateConnection(string connectionString) + => new SQLiteConnection(connectionString); + } } ``` +Also, make sure you specify the DbConfigurationType on the DBContext class as well + +```csharp +[DbConfigurationType(typeof(MyConfiguration))] +public class Context: DbContext { + //... DBContext things +} +``` ## Structure The code is written in an extensible way. From 27c3955ad6f22f1dbc2071ca466722fd41185d41 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 12 Aug 2021 11:35:56 +0200 Subject: [PATCH 31/56] Update README.md --- README.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/README.md b/README.md index 2fbfd3e..90d4f97 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,13 @@ To support this project you can: *star the repository*, report bugs/request feat Especially if you use it for a commercial project, a donation is welcome. If you need a specific feature for a commercial project, I am glad to offer a paid implementation. +## Project Status + +This project was started when there was .NET Full Framework and EF 6. EF 6 does not offer code first for SQLite and this library fills this gab. +Nowadays there is .NET Core (or now just called .NET) and EF Core. EF Core supports code first and migrations for SQLite. +If you use .NET Core 3 or above together with EF Core, there is no need for this library. +If you use EF 6 (either with .NET Full Framework or with .NET Core 3 or above), this library is an option for you to get code first for SQLite. + ## Features This project ships several `IDbInitializer` classes. These create new SQLite Databases based on your model/code. From 45790721d3cee62019f0ce09e9fe0f13c836d903 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 12 Aug 2021 11:37:42 +0200 Subject: [PATCH 32/56] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 90d4f97..d3cb00b 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ This project was started when there was .NET Full Framework and EF 6. EF 6 does Nowadays there is .NET Core (or now just called .NET) and EF Core. EF Core supports code first and migrations for SQLite. If you use .NET Core 3 or above together with EF Core, there is no need for this library. If you use EF 6 (either with .NET Full Framework or with .NET Core 3 or above), this library is an option for you to get code first for SQLite. +I'm going to maintain this library as long as it is useful for some people (see #157). ## Features From 7d593742a311b51a0c903405626255082cac6286 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 12 Aug 2021 11:40:31 +0200 Subject: [PATCH 33/56] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d3cb00b..8d987cc 100644 --- a/README.md +++ b/README.md @@ -18,7 +18,7 @@ This project was started when there was .NET Full Framework and EF 6. EF 6 does Nowadays there is .NET Core (or now just called .NET) and EF Core. EF Core supports code first and migrations for SQLite. If you use .NET Core 3 or above together with EF Core, there is no need for this library. If you use EF 6 (either with .NET Full Framework or with .NET Core 3 or above), this library is an option for you to get code first for SQLite. -I'm going to maintain this library as long as it is useful for some people (see #157). +I'm going to maintain this library as long as it is useful for some people (see [History](https://github.com/msallin/SQLiteCodeFirst/issues/166) & [Project Status and Release Schedule](https://github.com/msallin/SQLiteCodeFirst/issues/157)). ## Features From 14d91e749ea762f8679aa345a74f66a4a60e6631 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Thu, 12 Aug 2021 16:33:44 +0200 Subject: [PATCH 34/56] Update dependencies --- SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj | 2 +- .../SQLite.CodeFirst.NetCore.Console.csproj | 4 ++-- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 21dfe61..65325d8 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -10,7 +10,7 @@ ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - + diff --git a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj index 119d9ae..8b6b0d2 100644 --- a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj +++ b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj @@ -6,8 +6,8 @@ - - + + diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 687c599..13b7cfc 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -15,9 +15,9 @@ - - - + + + From a79bda11ca83e37c19788b3f2906d1093de92c19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergio=20Mart=C3=ADn=20Fern=C3=A1ndez?= Date: Wed, 7 Feb 2024 16:40:11 +0100 Subject: [PATCH 35/56] Make SQLLiteCodeFirst FIPS compliant This PR makes SQLiteCodeFirst FIPS compliant, needed to operate on US federal or many state government systems as it is a requirement for software vendors, replacing the SHA512Managed class with the SHA512CryptoServiceProvider. What is FIPS compliance? FIPS stands for Federal Information Processing Standards and are US Government standards that provide a benchmark for implementing cryptographic software SHA512CryptoServiceProvider uses the FIPS 140-2 validated (FIPS = Federal Information Processing Standards) Crypto Service Provider (CSP) while SHA256Managed does not. --- SQLite.CodeFirst/Internal/Utility/HashCreator.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SQLite.CodeFirst/Internal/Utility/HashCreator.cs b/SQLite.CodeFirst/Internal/Utility/HashCreator.cs index bd16c54..f8732a6 100644 --- a/SQLite.CodeFirst/Internal/Utility/HashCreator.cs +++ b/SQLite.CodeFirst/Internal/Utility/HashCreator.cs @@ -9,7 +9,7 @@ internal static class HashCreator public static string CreateHash(string data) { byte[] dataBytes = Encoding.ASCII.GetBytes(data); - using (SHA512 sha512 = new SHA512Managed()) + using (SHA512 sha512 = SHA512.Create()) { byte[] hashBytes = sha512.ComputeHash(dataBytes); string hash = Convert.ToBase64String(hashBytes); From a01fd39b25ff063bbb87935304a34be8d8344c64 Mon Sep 17 00:00:00 2001 From: "Sallin Marc, I212" Date: Fri, 23 Feb 2024 13:06:02 +0100 Subject: [PATCH 36/56] update dependencies --- README.md | 2 +- SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj | 2 +- .../SQLite.CodeFirst.NetCore.Console.csproj | 6 +++--- SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj | 8 ++++---- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index 8d987cc..63d7eb2 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ You can use the SQLite CodeFirst in projects that target the following framework - .NET 4.0 (uses net40) - .NET 4.5-4.8 (uses net45) - .NET Core 3.0-3.1 (uses netstandard2.1) -- .NET 5 (uses netstandard2.1) +- .NET 5-8 (uses netstandard2.1) ## How to use diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 65325d8..0ba463e 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -10,7 +10,7 @@ ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - + diff --git a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj index 8b6b0d2..5b2fa34 100644 --- a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj +++ b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj @@ -2,12 +2,12 @@ Exe - net5.0 + net8.0 - - + + diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 13b7cfc..a0798e2 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -14,10 +14,10 @@ pdbonly - - - - + + + + From 78c556b8a03d0ea33ef41f4fa4e1fc655a958547 Mon Sep 17 00:00:00 2001 From: "Sallin Marc, I212" Date: Fri, 23 Feb 2024 13:08:55 +0100 Subject: [PATCH 37/56] update ci --- ci_appveyor.yml | 2 +- release_appveyor.yml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci_appveyor.yml b/ci_appveyor.yml index bc7ecb2..36b0af4 100644 --- a/ci_appveyor.yml +++ b/ci_appveyor.yml @@ -1,5 +1,5 @@ version: CI_{branch}_{build} -image: Visual Studio 2019 +image: Visual Studio 2022 skip_tags: true configuration: - Release diff --git a/release_appveyor.yml b/release_appveyor.yml index 0945e76..be4baa2 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -1,5 +1,5 @@ version: 1.7.0.{build} -image: Visual Studio 2019 +image: Visual Studio 2022 branches: only: - master @@ -30,7 +30,7 @@ deploy: # Encrypt with https://ci.appveyor.com/tools/encrypt - provider: NuGet api_key: - secure: /mFKbp4C8bazwSgH5C6JakY8dZEffGRekipyvAUCkYJ+sfQhtsLDrKGek1oTrbAx + secure: fdOvSLLttfWbXxkmrgNG+jfczNAqx0HOIqYeVhToHGvezVwts758wz+sbGkv2RhZ on: branch: master - provider: GitHub From cf9fde252dc9b35b00aea00b91afd4f5dda67b89 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 01:54:14 +0200 Subject: [PATCH 38/56] Migrate to .NET 10, update dependencies, and modernize test tooling - Target net10.0 in the .NET Core console demo and the test project (the test project moves off net48). - Point the test project at the .NET Core demo project and register the EF6 SQLite provider through a code-based DbConfiguration, since modern .NET has no app.config provider discovery. Sign the demo so the signed test assembly can reference it. - Update dependencies: EntityFramework 6.5.2, System.Data.SQLite(.EF6) 1.0.119, Moq 4.20.72, MSTest 4.2.3. - Convert the solution from .sln to .slnx. - Run the unit tests on Microsoft.Testing.Platform (MSTest runner), opted in via global.json. - Adapt the tests to MSTest 4: replace [ExpectedException] with Assert.ThrowsExactly and fix Assert.AreEqual argument order. - Replace the package's deprecated licenseUrl with the SPDX expression Apache-2.0. --- .../SQLite.CodeFirst.Console.csproj | 2 +- .../SQLite.CodeFirst.NetCore.Console.csproj | 10 ++-- .../InMemoryDbCreationTest.cs | 4 +- .../SqlGenerationDefaultCollationTest.cs | 4 +- .../IntegrationTests/SqlGenerationTest.cs | 4 +- .../SQLite.CodeFirst.Test.csproj | 27 ++++----- SQLite.CodeFirst.Test/TestSetup.cs | 23 ++++++++ .../ColumnConstraint/CollateConstraintTest.cs | 4 +- .../ColumnConstraintCollectionTest.cs | 4 +- .../DefaultValueConstraintTest.cs | 6 +- .../ColumnConstraint/MaxLengthConstraint.cs | 5 +- .../ColumnConstraint/NotNullConstraintTest.cs | 2 +- .../PrimaryKeyConstraintTest.cs | 4 +- .../ColumnConstraint/UniqueConstraintTest.cs | 4 +- .../ColumnStatementCollectionTest.cs | 8 +-- .../Statement/ColumnStatementTest.cs | 2 +- .../Statement/CreateDatabaseStatementTest.cs | 8 +-- .../CreateIndexStatementCollectionTest.cs | 8 +-- .../Statement/CreateTableStatementTest.cs | 2 +- .../Statement/ForeignKeyStatementTest.cs | 10 ++-- .../Statement/PrimaryKeyStatementTest.cs | 8 +-- .../Utility/HistoryEntityTypeValidatorTest.cs | 8 +-- SQLite.CodeFirst.Test/app.config | 32 ----------- SQLite.CodeFirst.sln | 55 ------------------- SQLite.CodeFirst.slnx | 15 +++++ SQLite.CodeFirst/SQLite.CodeFirst.csproj | 4 +- ci_appveyor.yml | 2 +- global.json | 5 ++ release_appveyor.yml | 2 +- 29 files changed, 111 insertions(+), 161 deletions(-) create mode 100644 SQLite.CodeFirst.Test/TestSetup.cs delete mode 100644 SQLite.CodeFirst.Test/app.config delete mode 100644 SQLite.CodeFirst.sln create mode 100644 SQLite.CodeFirst.slnx create mode 100644 global.json diff --git a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj index 0ba463e..95f93db 100644 --- a/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj +++ b/SQLite.CodeFirst.Console/SQLite.CodeFirst.Console.csproj @@ -10,7 +10,7 @@ ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - + diff --git a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj index 5b2fa34..d8dbac3 100644 --- a/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj +++ b/SQLite.CodeFirst.NetCore.Console/SQLite.CodeFirst.NetCore.Console.csproj @@ -1,13 +1,15 @@ - + Exe - net8.0 + net10.0 + true + ..\Shared\SQLite.CodeFirst.StrongNameKey.snk - - + + diff --git a/SQLite.CodeFirst.Test/IntegrationTests/InMemoryDbCreationTest.cs b/SQLite.CodeFirst.Test/IntegrationTests/InMemoryDbCreationTest.cs index c707341..d5ef6ab 100644 --- a/SQLite.CodeFirst.Test/IntegrationTests/InMemoryDbCreationTest.cs +++ b/SQLite.CodeFirst.Test/IntegrationTests/InMemoryDbCreationTest.cs @@ -1,8 +1,8 @@ using System.Collections.Generic; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; -using SQLite.CodeFirst.Console; -using SQLite.CodeFirst.Console.Entity; +using SQLite.CodeFirst.NetCore.Console; +using SQLite.CodeFirst.NetCore.Console.Entity; namespace SQLite.CodeFirst.Test.IntegrationTests { diff --git a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs index d6cbd08..35acd38 100644 --- a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs +++ b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationDefaultCollationTest.cs @@ -4,8 +4,8 @@ using System.Data.SQLite; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; -using SQLite.CodeFirst.Console; -using SQLite.CodeFirst.Console.Entity; +using SQLite.CodeFirst.NetCore.Console; +using SQLite.CodeFirst.NetCore.Console.Entity; namespace SQLite.CodeFirst.Test.IntegrationTests { diff --git a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs index 6be0a61..22b3efa 100644 --- a/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs +++ b/SQLite.CodeFirst.Test/IntegrationTests/SqlGenerationTest.cs @@ -4,8 +4,8 @@ using System.Data.SQLite; using System.Linq; using Microsoft.VisualStudio.TestTools.UnitTesting; -using SQLite.CodeFirst.Console; -using SQLite.CodeFirst.Console.Entity; +using SQLite.CodeFirst.NetCore.Console; +using SQLite.CodeFirst.NetCore.Console.Entity; namespace SQLite.CodeFirst.Test.IntegrationTests { diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index a0798e2..ece4fdb 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -1,29 +1,22 @@ - + - net48 + net10.0 SQLite.CodeFirst.Test Contains the Unit Tests for the SQLite.CodeFirst Library. 1.0.0.0 true ..\Shared\SQLite.CodeFirst.StrongNameKey.snk + + Exe + true - - full - - - pdbonly - - - - - - - - + + + - + - \ No newline at end of file + diff --git a/SQLite.CodeFirst.Test/TestSetup.cs b/SQLite.CodeFirst.Test/TestSetup.cs new file mode 100644 index 0000000..e180699 --- /dev/null +++ b/SQLite.CodeFirst.Test/TestSetup.cs @@ -0,0 +1,23 @@ +using System.Data.Entity; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SQLite.CodeFirst.NetCore.Console; + +namespace SQLite.CodeFirst.Test +{ + /// + /// Registers the SQLite Entity Framework 6 provider once for the whole test assembly. + /// On .NET (Core) there is no app.config based provider discovery, so the code based + /// from the demo project is applied before any test runs. + /// Setting it explicitly (instead of relying on assembly scanning) makes the registration + /// independent of which DbContext the test runner happens to touch first. + /// + [TestClass] + public static class TestSetup + { + [AssemblyInitialize] + public static void Initialize(TestContext context) + { + DbConfiguration.SetConfiguration(new Configuration()); + } + } +} diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/CollateConstraintTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/CollateConstraintTest.cs index 8697d24..bc02127 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/CollateConstraintTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/CollateConstraintTest.cs @@ -12,7 +12,7 @@ public void CreateStatement_StatementIsCorrect_NoConstraint() var collationConstraint = new CollateConstraint(); collationConstraint.CollationFunction = CollationFunction.None; string output = collationConstraint.CreateStatement(); - Assert.AreEqual(output, ""); + Assert.AreEqual("", output); } [TestMethod] @@ -21,7 +21,7 @@ public void CreateStatement_StatementIsCorrect_NoCase() var collationConstraint = new CollateConstraint(); collationConstraint.CollationFunction = CollationFunction.NoCase; string output = collationConstraint.CreateStatement(); - Assert.AreEqual(output, "COLLATE NOCASE"); + Assert.AreEqual("COLLATE NOCASE", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/ColumnConstraintCollectionTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/ColumnConstraintCollectionTest.cs index eb6aa47..08def45 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/ColumnConstraintCollectionTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/ColumnConstraintCollectionTest.cs @@ -18,7 +18,7 @@ public void CreateStatementOneColumnConstraintTest() columnConstraintMock.Object }); string output = columnConstraintCollection.CreateStatement(); - Assert.AreEqual(output, "dummy1"); + Assert.AreEqual("dummy1", output); } [TestMethod] @@ -36,7 +36,7 @@ public void CreateStatementTwoColumnConstraintsTest() columnConstraintMock2.Object }); string output = columnConstraintCollection.CreateStatement(); - Assert.AreEqual(output, "dummy1 dummy2"); + Assert.AreEqual("dummy1 dummy2", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/DefaultValueConstraintTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/DefaultValueConstraintTest.cs index da2a20a..a8b01b1 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/DefaultValueConstraintTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/DefaultValueConstraintTest.cs @@ -12,7 +12,7 @@ public void CreateStatement_StatementIsCorrect_IntDefault() var defaultValueConstraint = new DefaultValueConstraint(); defaultValueConstraint.DefaultValue = "0"; string output = defaultValueConstraint.CreateStatement(); - Assert.AreEqual(output, "DEFAULT (0)"); + Assert.AreEqual("DEFAULT (0)", output); } [TestMethod] @@ -21,7 +21,7 @@ public void CreateStatement_StatementIsCorrect_StringDefault() var defaultValueConstraint = new DefaultValueConstraint(); defaultValueConstraint.DefaultValue = @"'Something'"; string output = defaultValueConstraint.CreateStatement(); - Assert.AreEqual(output, "DEFAULT ('Something')"); + Assert.AreEqual("DEFAULT ('Something')", output); } [TestMethod] @@ -30,7 +30,7 @@ public void CreateStatement_StatementIsCorrect_ExpressionDefault() var defaultValueConstraint = new DefaultValueConstraint(); defaultValueConstraint.DefaultValue = @"datetime('now')"; string output = defaultValueConstraint.CreateStatement(); - Assert.AreEqual(output, "DEFAULT (datetime('now'))"); + Assert.AreEqual("DEFAULT (datetime('now'))", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/MaxLengthConstraint.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/MaxLengthConstraint.cs index 1df077f..3436359 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/MaxLengthConstraint.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/MaxLengthConstraint.cs @@ -12,15 +12,14 @@ public void CreateStatementTest() { var maxLengthConstraint = new MaxLengthConstraint(12); string output = maxLengthConstraint.CreateStatement(); - Assert.AreEqual(output, "(12)"); + Assert.AreEqual("(12)", output); } [TestMethod] - [ExpectedException(typeof(InvalidOperationException))] public void CreateStatementInvalidParameterTest() { var maxLengthConstraint = new MaxLengthConstraint(); - maxLengthConstraint.CreateStatement(); + Assert.ThrowsExactly(() => maxLengthConstraint.CreateStatement()); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/NotNullConstraintTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/NotNullConstraintTest.cs index 747fdbf..59ea347 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/NotNullConstraintTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/NotNullConstraintTest.cs @@ -11,7 +11,7 @@ public void CreateStatementTest() { var notNullConstraint = new NotNullConstraint(); string output = notNullConstraint.CreateStatement(); - Assert.AreEqual(output, "NOT NULL"); + Assert.AreEqual("NOT NULL", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/PrimaryKeyConstraintTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/PrimaryKeyConstraintTest.cs index 5d5bc6d..71a9aea 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/PrimaryKeyConstraintTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/PrimaryKeyConstraintTest.cs @@ -11,7 +11,7 @@ public void CreateStatement_StatementIsCorrect_WithAutoincrement() { var primaryKeyConstraint = new PrimaryKeyConstraint { Autoincrement = true }; string output = primaryKeyConstraint.CreateStatement(); - Assert.AreEqual(output, "PRIMARY KEY AUTOINCREMENT"); + Assert.AreEqual("PRIMARY KEY AUTOINCREMENT", output); } [TestMethod] @@ -19,7 +19,7 @@ public void CreateStatement_StatementIsCorrect() { var primaryKeyConstraint = new PrimaryKeyConstraint(); string output = primaryKeyConstraint.CreateStatement(); - Assert.AreEqual(output, "PRIMARY KEY"); + Assert.AreEqual("PRIMARY KEY", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/UniqueConstraintTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/UniqueConstraintTest.cs index d09e2c5..ece92e1 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/UniqueConstraintTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnConstraint/UniqueConstraintTest.cs @@ -12,7 +12,7 @@ public void CreateStatement_StatementIsCorrect_NoConstraint() var uniqueConstraint = new UniqueConstraint(); uniqueConstraint.OnConflict = OnConflictAction.None; string output = uniqueConstraint.CreateStatement(); - Assert.AreEqual(output, "UNIQUE"); + Assert.AreEqual("UNIQUE", output); } [TestMethod] @@ -21,7 +21,7 @@ public void CreateStatement_StatementIsCorrect_WithConstraint() var uniqueConstraint = new UniqueConstraint(); uniqueConstraint.OnConflict = OnConflictAction.Rollback; string output = uniqueConstraint.CreateStatement(); - Assert.AreEqual(output, "UNIQUE ON CONFLICT ROLLBACK"); + Assert.AreEqual("UNIQUE ON CONFLICT ROLLBACK", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementCollectionTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementCollectionTest.cs index eccb3fb..d40913b 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementCollectionTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementCollectionTest.cs @@ -12,8 +12,8 @@ public void CreateStatementOneEntryTest() var columnStatementCollection = new ColumnStatementCollection(new[] { CreateStatementMock("dummy1").Object }); string output = columnStatementCollection.CreateStatement(); - Assert.AreEqual(columnStatementCollection.Count, 1); - Assert.AreEqual(output, "dummy1"); + Assert.AreEqual(1, columnStatementCollection.Count); + Assert.AreEqual("dummy1", output); } [TestMethod] @@ -26,8 +26,8 @@ public void CreateStatementTwoEntryTest() }); string output = createIndexStatementCollection.CreateStatement(); - Assert.AreEqual(createIndexStatementCollection.Count, 2); - Assert.AreEqual(output, "dummy1, dummy2"); + Assert.AreEqual(2, createIndexStatementCollection.Count); + Assert.AreEqual("dummy1, dummy2", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs index 9e47dc5..7643abc 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ColumnStatementTest.cs @@ -21,7 +21,7 @@ public void CreateStatement() ColumnConstraints = columnConstraintsMock.Object, }; string output = columnStatement.CreateStatement(); - Assert.AreEqual(output, "[dummyColumnName] dummyType dummyColumnConstraint"); + Assert.AreEqual("[dummyColumnName] dummyType dummyColumnConstraint", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/CreateDatabaseStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/CreateDatabaseStatementTest.cs index 33e4f39..888574e 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/CreateDatabaseStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/CreateDatabaseStatementTest.cs @@ -16,8 +16,8 @@ public void CreateStatementWithOneKeyTest() }; var createDatabaseStatement = new CreateDatabaseStatement(statements); - Assert.AreEqual(createDatabaseStatement.Count, 1); - Assert.AreEqual(createDatabaseStatement.CreateStatement(), "dummy1"); + Assert.AreEqual(1, createDatabaseStatement.Count); + Assert.AreEqual("dummy1", createDatabaseStatement.CreateStatement()); } [TestMethod] @@ -30,8 +30,8 @@ public void CreateStatementWithTwoKeyTest() }; var createDatabaseStatement = new CreateDatabaseStatement(statements); - Assert.AreEqual(createDatabaseStatement.Count, 2); - Assert.AreEqual(createDatabaseStatement.CreateStatement(), "dummy1\r\ndummy2"); + Assert.AreEqual(2, createDatabaseStatement.Count); + Assert.AreEqual("dummy1\r\ndummy2", createDatabaseStatement.CreateStatement()); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/CreateIndexStatementCollectionTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/CreateIndexStatementCollectionTest.cs index 1082710..b90626c 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/CreateIndexStatementCollectionTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/CreateIndexStatementCollectionTest.cs @@ -15,8 +15,8 @@ public void CreateStatementOneEntryTest() }); string output = createIndexStatementCollection.CreateStatement(); - Assert.AreEqual(createIndexStatementCollection.Count, 1); - Assert.AreEqual(output, "dummy1"); + Assert.AreEqual(1, createIndexStatementCollection.Count); + Assert.AreEqual("dummy1", output); } [TestMethod] @@ -29,8 +29,8 @@ public void CreateStatementTwoEntryTest() }); string output = createIndexStatementCollection.CreateStatement(); - Assert.AreEqual(createIndexStatementCollection.Count, 2); - Assert.AreEqual(output, "dummy1\r\ndummy2"); + Assert.AreEqual(2, createIndexStatementCollection.Count); + Assert.AreEqual("dummy1\r\ndummy2", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/CreateTableStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/CreateTableStatementTest.cs index 31d3817..1d19219 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/CreateTableStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/CreateTableStatementTest.cs @@ -16,7 +16,7 @@ public void CreateStatementTest() }; string output = createTableStatement.CreateStatement(); - Assert.AreEqual(output, "CREATE TABLE dummyTable (dummyColumnDefinition);"); + Assert.AreEqual("CREATE TABLE dummyTable (dummyColumnDefinition);", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs index c3472de..0a8ac9f 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs @@ -19,7 +19,7 @@ public void CreateStatementOneForeignKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])"); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])", output); } [TestMethod] @@ -34,7 +34,7 @@ public void CreateStatementOneForeignKeyCascadeDeleteTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE"); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE", output); } [TestMethod] @@ -49,7 +49,7 @@ public void CreateStatementTwoForeignKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])"); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1])", output); } [TestMethod] @@ -64,7 +64,7 @@ public void CreateStatementTwoForeignKeyTwoPrimaryKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])"); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1], [dummyForeignKey2]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])", output); } [TestMethod] @@ -79,7 +79,7 @@ public void CreateStatementOneForeignKeyTwoPrimaryKeyTest() }; string output = foreignKeyStatement.CreateStatement(); - Assert.AreEqual(output, "FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])"); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1], [dummForeignPrimaryKey2])", output); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs index beffd06..b83d2c1 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/PrimaryKeyStatementTest.cs @@ -13,8 +13,8 @@ public void CreateStatementWithOneKeyTest() const string keyMember1 = "keyMember1"; var primaryKeyStatement = new CompositePrimaryKeyStatement(new List { keyMember1 }); - Assert.AreEqual(primaryKeyStatement.Count, 1); - Assert.AreEqual(primaryKeyStatement.CreateStatement(), "PRIMARY KEY([keyMember1])"); + Assert.AreEqual(1, primaryKeyStatement.Count); + Assert.AreEqual("PRIMARY KEY([keyMember1])", primaryKeyStatement.CreateStatement()); } [TestMethod] @@ -24,8 +24,8 @@ public void CreateStatementWithTwoKeyTest() const string keyMember2 = "keyMember2"; var primaryKeyStatement = new CompositePrimaryKeyStatement(new List { keyMember1, keyMember2 }); - Assert.AreEqual(primaryKeyStatement.Count, 2); - Assert.AreEqual(primaryKeyStatement.CreateStatement(), "PRIMARY KEY([keyMember1], [keyMember2])"); + Assert.AreEqual(2, primaryKeyStatement.Count); + Assert.AreEqual("PRIMARY KEY([keyMember1], [keyMember2])", primaryKeyStatement.CreateStatement()); } } } diff --git a/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryEntityTypeValidatorTest.cs b/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryEntityTypeValidatorTest.cs index 61fcfb2..590c735 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryEntityTypeValidatorTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryEntityTypeValidatorTest.cs @@ -8,17 +8,17 @@ namespace SQLite.CodeFirst.Test.UnitTests.Utility public class HistoryEntityTypeValidatorTest { [TestMethod] - [ExpectedException(typeof(InvalidOperationException))] public void EnsureValidTypeNotIHistory() { - HistoryEntityTypeValidator.EnsureValidType(typeof(InvalidFakeHistoryType1)); + Assert.ThrowsExactly( + () => HistoryEntityTypeValidator.EnsureValidType(typeof(InvalidFakeHistoryType1))); } [TestMethod] - [ExpectedException(typeof(InvalidOperationException))] public void EnsureValidTypeNoParamLessCtorTest() { - HistoryEntityTypeValidator.EnsureValidType(typeof(InvalidFakeHistoryType2)); + Assert.ThrowsExactly( + () => HistoryEntityTypeValidator.EnsureValidType(typeof(InvalidFakeHistoryType2))); } [TestMethod] diff --git a/SQLite.CodeFirst.Test/app.config b/SQLite.CodeFirst.Test/app.config deleted file mode 100644 index 2f401ce..0000000 --- a/SQLite.CodeFirst.Test/app.config +++ /dev/null @@ -1,32 +0,0 @@ - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/SQLite.CodeFirst.sln b/SQLite.CodeFirst.sln deleted file mode 100644 index 856e8f8..0000000 --- a/SQLite.CodeFirst.sln +++ /dev/null @@ -1,55 +0,0 @@ -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 16 -VisualStudioVersion = 16.0.29503.13 -MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite.CodeFirst", "SQLite.CodeFirst\SQLite.CodeFirst.csproj", "{50A32FE4-0E13-4213-A373-72523CDF34D9}" -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite.CodeFirst.Console", "SQLite.CodeFirst.Console\SQLite.CodeFirst.Console.csproj", "{DEDABD86-6EA0-4673-A858-A4F71958F51D}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Build", "Build", "{7031BD3C-AE76-43CD-91B6-B6BCD823968C}" - ProjectSection(SolutionItems) = preProject - ci_appveyor.yml = ci_appveyor.yml - release_appveyor.yml = release_appveyor.yml - EndProjectSection -EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SQLite.CodeFirst.Test", "SQLite.CodeFirst.Test\SQLite.CodeFirst.Test.csproj", "{E542F38D-852E-489D-81C2-BF333503E10F}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Shared", "Shared", "{1F6D4E0E-5D07-4889-961A-A6AFC0ECD7C7}" - ProjectSection(SolutionItems) = preProject - README.md = README.md - Shared\SQLite.CodeFirst.ruleset = Shared\SQLite.CodeFirst.ruleset - Shared\SQLite.CodeFirst.StrongNameKey.snk = Shared\SQLite.CodeFirst.StrongNameKey.snk - EndProjectSection -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SQLite.CodeFirst.NetCore.Console", "SQLite.CodeFirst.NetCore.Console\SQLite.CodeFirst.NetCore.Console.csproj", "{709F46E3-D23B-4931-9985-8E09E3817CC4}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {50A32FE4-0E13-4213-A373-72523CDF34D9}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {50A32FE4-0E13-4213-A373-72523CDF34D9}.Debug|Any CPU.Build.0 = Debug|Any CPU - {50A32FE4-0E13-4213-A373-72523CDF34D9}.Release|Any CPU.ActiveCfg = Release|Any CPU - {50A32FE4-0E13-4213-A373-72523CDF34D9}.Release|Any CPU.Build.0 = Release|Any CPU - {DEDABD86-6EA0-4673-A858-A4F71958F51D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {DEDABD86-6EA0-4673-A858-A4F71958F51D}.Debug|Any CPU.Build.0 = Debug|Any CPU - {DEDABD86-6EA0-4673-A858-A4F71958F51D}.Release|Any CPU.ActiveCfg = Release|Any CPU - {DEDABD86-6EA0-4673-A858-A4F71958F51D}.Release|Any CPU.Build.0 = Release|Any CPU - {E542F38D-852E-489D-81C2-BF333503E10F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E542F38D-852E-489D-81C2-BF333503E10F}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E542F38D-852E-489D-81C2-BF333503E10F}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E542F38D-852E-489D-81C2-BF333503E10F}.Release|Any CPU.Build.0 = Release|Any CPU - {709F46E3-D23B-4931-9985-8E09E3817CC4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {709F46E3-D23B-4931-9985-8E09E3817CC4}.Debug|Any CPU.Build.0 = Debug|Any CPU - {709F46E3-D23B-4931-9985-8E09E3817CC4}.Release|Any CPU.ActiveCfg = Release|Any CPU - {709F46E3-D23B-4931-9985-8E09E3817CC4}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(ExtensibilityGlobals) = postSolution - SolutionGuid = {D21CDFB4-5695-4346-AB51-48C80AED4418} - EndGlobalSection -EndGlobal diff --git a/SQLite.CodeFirst.slnx b/SQLite.CodeFirst.slnx new file mode 100644 index 0000000..a6f7881 --- /dev/null +++ b/SQLite.CodeFirst.slnx @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + diff --git a/SQLite.CodeFirst/SQLite.CodeFirst.csproj b/SQLite.CodeFirst/SQLite.CodeFirst.csproj index 954af58..ee45773 100644 --- a/SQLite.CodeFirst/SQLite.CodeFirst.csproj +++ b/SQLite.CodeFirst/SQLite.CodeFirst.csproj @@ -10,7 +10,7 @@ https://github.com/msallin/SQLiteCodeFirst GitHub true - https://github.com/msallin/SQLiteCodeFirst/blob/master/LICENSE + Apache-2.0 false Copyright (C) Marc Sallin SQLite EntityFramework EF CodeFirst @@ -20,7 +20,7 @@ - + diff --git a/ci_appveyor.yml b/ci_appveyor.yml index 36b0af4..0e22b91 100644 --- a/ci_appveyor.yml +++ b/ci_appveyor.yml @@ -9,7 +9,7 @@ before_build: - ps: dotnet --version - ps: dotnet restore build: - project: SQLite.CodeFirst.sln + project: SQLite.CodeFirst.slnx parallel: true verbosity: normal artifacts: diff --git a/global.json b/global.json new file mode 100644 index 0000000..3140116 --- /dev/null +++ b/global.json @@ -0,0 +1,5 @@ +{ + "test": { + "runner": "Microsoft.Testing.Platform" + } +} diff --git a/release_appveyor.yml b/release_appveyor.yml index be4baa2..9c7ff5b 100644 --- a/release_appveyor.yml +++ b/release_appveyor.yml @@ -18,7 +18,7 @@ before_build: - ps: dotnet --version - ps: dotnet restore build: - project: SQLite.CodeFirst.sln + project: SQLite.CodeFirst.slnx parallel: true verbosity: normal artifacts: From 087cc7103261a9dd6cdaa850463aa368a3f1ca87 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 01:56:14 +0200 Subject: [PATCH 39/56] Use NuGet lock files Enable RestorePackagesWithLockFile via Directory.Build.props so restore pins the full transitive package graph in a packages.lock.json per project. This makes restores reproducible and lets CI restore in locked mode to catch any lock file that is missing or out of date. --- Directory.Build.props | 11 + SQLite.CodeFirst.Console/packages.lock.json | 55 ++++ .../packages.lock.json | 142 ++++++++++ SQLite.CodeFirst.Test/packages.lock.json | 246 ++++++++++++++++++ SQLite.CodeFirst/packages.lock.json | 208 +++++++++++++++ 5 files changed, 662 insertions(+) create mode 100644 Directory.Build.props create mode 100644 SQLite.CodeFirst.Console/packages.lock.json create mode 100644 SQLite.CodeFirst.NetCore.Console/packages.lock.json create mode 100644 SQLite.CodeFirst.Test/packages.lock.json create mode 100644 SQLite.CodeFirst/packages.lock.json diff --git a/Directory.Build.props b/Directory.Build.props new file mode 100644 index 0000000..4dcd0ff --- /dev/null +++ b/Directory.Build.props @@ -0,0 +1,11 @@ + + + + + true + + + diff --git a/SQLite.CodeFirst.Console/packages.lock.json b/SQLite.CodeFirst.Console/packages.lock.json new file mode 100644 index 0000000..fe32642 --- /dev/null +++ b/SQLite.CodeFirst.Console/packages.lock.json @@ -0,0 +1,55 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.8": { + "System.Data.SQLite": { + "type": "Direct", + "requested": "[1.0.119, )", + "resolved": "1.0.119", + "contentHash": "JSOJpnBf9goMnxGTJFGCmm6AffxgtpuXNXV5YvWO8UNC2zwd12qkUe5lAbnY+2ohIkIukgIjbvR1RA/sWILv3w==", + "dependencies": { + "System.Data.SQLite.Core": "[1.0.119]", + "System.Data.SQLite.EF6": "[1.0.119]", + "System.Data.SQLite.Linq": "[1.0.119]" + } + }, + "EntityFramework": { + "type": "Transitive", + "resolved": "6.5.2", + "contentHash": "8iOcnaKcgkWh35s8EhknnENNwwqvrBJ7jeNbQITbGo1mIeIOhGPfVdNOXZ3Y496T6e6wfXvz0WeXlgMdcgVYSA==" + }, + "Stub.System.Data.SQLite.Core.NetFramework": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "8b4SbSXAxXJ8tfn6bnBu0m+HXMZvkE+BfogUKITRFm+snxfT5BTK7fLZaAsNoFX8DkBBjtCEDd+ajWkcyu55QA==" + }, + "System.Data.SQLite.Core": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "bhQB8HVtRA+OOYw8UTD1F1kU+nGJ0/OZvH1JmlVUI4bGvgVEWeX1NcHjA765NvUoRVuCPlt8PrEpZ1thSsk1jg==", + "dependencies": { + "Stub.System.Data.SQLite.Core.NetFramework": "[1.0.119]" + } + }, + "System.Data.SQLite.EF6": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "BwwgCSeA80gsxdXtU7IQEBrN9kQXWQrD11hNYOJZbXBBI1C4r7hA4QhBAalO1nzijXikthGRUADIEMI3nlucLA==", + "dependencies": { + "EntityFramework": "6.4.4" + } + }, + "System.Data.SQLite.Linq": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "tkzb9aKEiQd18UW8VS6+vGtrkhcp4mjHg/AAKwNN8u7aWoBswquOnU07016MfTXyBUAR67mepWUhFC8zqNdPnA==" + }, + "sqlite.codefirst": { + "type": "Project", + "dependencies": { + "EntityFramework": "[6.5.2, )" + } + } + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.NetCore.Console/packages.lock.json b/SQLite.CodeFirst.NetCore.Console/packages.lock.json new file mode 100644 index 0000000..c50d503 --- /dev/null +++ b/SQLite.CodeFirst.NetCore.Console/packages.lock.json @@ -0,0 +1,142 @@ +{ + "version": 1, + "dependencies": { + "net10.0": { + "System.Data.SQLite": { + "type": "Direct", + "requested": "[1.0.119, )", + "resolved": "1.0.119", + "contentHash": "JSOJpnBf9goMnxGTJFGCmm6AffxgtpuXNXV5YvWO8UNC2zwd12qkUe5lAbnY+2ohIkIukgIjbvR1RA/sWILv3w==", + "dependencies": { + "System.Data.SQLite.Core": "[1.0.119]", + "System.Data.SQLite.EF6": "[1.0.119]" + } + }, + "System.Data.SQLite.EF6": { + "type": "Direct", + "requested": "[1.0.119, )", + "resolved": "1.0.119", + "contentHash": "BwwgCSeA80gsxdXtU7IQEBrN9kQXWQrD11hNYOJZbXBBI1C4r7hA4QhBAalO1nzijXikthGRUADIEMI3nlucLA==", + "dependencies": { + "EntityFramework": "6.4.4" + } + }, + "EntityFramework": { + "type": "Transitive", + "resolved": "6.5.2", + "contentHash": "8iOcnaKcgkWh35s8EhknnENNwwqvrBJ7jeNbQITbGo1mIeIOhGPfVdNOXZ3Y496T6e6wfXvz0WeXlgMdcgVYSA==", + "dependencies": { + "System.CodeDom": "6.0.0", + "System.ComponentModel.Annotations": "5.0.0", + "System.Configuration.ConfigurationManager": "6.0.1", + "System.Data.SqlClient": "4.8.6" + } + }, + "Microsoft.Win32.SystemEvents": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A==" + }, + "runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "9kyFSIdN3T0qjDQ2R0HRXYIhS3l5psBzQi6qqhdLz+SzFyEy4sVxNOke+yyYv8Cu8rPER12c3RDjLT8wF3WBYQ==", + "dependencies": { + "runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": "4.4.0", + "runtime.win-x64.runtime.native.System.Data.SqlClient.sni": "4.4.0", + "runtime.win-x86.runtime.native.System.Data.SqlClient.sni": "4.4.0" + } + }, + "runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "LbrynESTp3bm5O/+jGL8v0Qg5SJlTV08lpIpFesXjF6uGNMWqFnUQbYBJwZTeua6E/Y7FIM1C54Ey1btLWupdg==" + }, + "runtime.win-x64.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "38ugOfkYJqJoX9g6EYRlZB5U2ZJH51UP8ptxZgdpS07FgOEToV+lS11ouNK2PM12Pr6X/PpT5jK82G3DwH/SxQ==" + }, + "runtime.win-x86.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "YhEdSQUsTx+C8m8Bw7ar5/VesXvCFMItyZF7G1AUY+OM0VPZUOeAVpJ4Wl6fydBGUYZxojTDR3I6Bj/+BPkJNA==" + }, + "Stub.System.Data.SQLite.Core.NetStandard": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "dI7ngiCNgdm+n00nQvFTa+LbHvE9MIQXwMSLRzJI/KAJ7G1WmCachsvfE1CD6xvb3OXJvYYEfv3+S/LHyhN0Rg==" + }, + "System.CodeDom": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "CPc6tWO1LAer3IzfZufDBRL+UZQcj5uS207NHALQzP84Vp/z6wF0Aa0YZImOQY8iStY0A2zI/e3ihKNPfUm8XA==" + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==" + }, + "System.Configuration.ConfigurationManager": { + "type": "Transitive", + "resolved": "6.0.1", + "contentHash": "jXw9MlUu/kRfEU0WyTptAVueupqIeE3/rl0EZDMlf8pcvJnitQ8HeVEp69rZdaStXwTV72boi/Bhw8lOeO+U2w==", + "dependencies": { + "System.Security.Cryptography.ProtectedData": "6.0.0", + "System.Security.Permissions": "6.0.0" + } + }, + "System.Data.SqlClient": { + "type": "Transitive", + "resolved": "4.8.6", + "contentHash": "2Ij/LCaTQRyAi5lAv7UUTV9R2FobC8xN9mE0fXBZohum/xLl8IZVmE98Rq5ugQHjCgTBRKqpXRb4ORulRdA6Ig==", + "dependencies": { + "runtime.native.System.Data.SqlClient.sni": "4.7.0" + } + }, + "System.Data.SQLite.Core": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "bhQB8HVtRA+OOYw8UTD1F1kU+nGJ0/OZvH1JmlVUI4bGvgVEWeX1NcHjA765NvUoRVuCPlt8PrEpZ1thSsk1jg==", + "dependencies": { + "Stub.System.Data.SQLite.Core.NetStandard": "[1.0.119]" + } + }, + "System.Drawing.Common": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "NfuoKUiP2nUWwKZN6twGqXioIe1zVD0RIj2t976A+czLHr2nY454RwwXs6JU9Htc6mwqL6Dn/nEL3dpVf2jOhg==", + "dependencies": { + "Microsoft.Win32.SystemEvents": "6.0.0" + } + }, + "System.Security.Cryptography.ProtectedData": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "rp1gMNEZpvx9vP0JW0oHLxlf8oSiQgtno77Y4PLUBjSiDYoD77Y8uXHr1Ea5XG4/pIKhqAdxZ8v8OTUtqo9PeQ==" + }, + "System.Security.Permissions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "T/uuc7AklkDoxmcJ7LGkyX1CcSviZuLCa4jg3PekfJ7SU0niF0IVTXwUiNVP9DSpzou2PpxJ+eNY2IfDM90ZCg==", + "dependencies": { + "System.Windows.Extensions": "6.0.0" + } + }, + "System.Windows.Extensions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "IXoJOXIqc39AIe+CIR7koBtRGMiCt/LPM3lI+PELtDIy9XdyeSrwXFdWV9dzJ2Awl0paLWUaknLxFQ5HpHZUog==", + "dependencies": { + "System.Drawing.Common": "6.0.0" + } + }, + "sqlite.codefirst": { + "type": "Project", + "dependencies": { + "EntityFramework": "[6.5.2, )" + } + } + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst.Test/packages.lock.json b/SQLite.CodeFirst.Test/packages.lock.json new file mode 100644 index 0000000..9420ea8 --- /dev/null +++ b/SQLite.CodeFirst.Test/packages.lock.json @@ -0,0 +1,246 @@ +{ + "version": 1, + "dependencies": { + "net10.0": { + "Moq": { + "type": "Direct", + "requested": "[4.20.72, )", + "resolved": "4.20.72", + "contentHash": "EA55cjyNn8eTNWrgrdZJH5QLFp2L43oxl1tlkoYUKIE9pRwL784OWiTXeCV5ApS+AMYEAlt7Fo03A2XfouvHmQ==", + "dependencies": { + "Castle.Core": "5.1.1" + } + }, + "MSTest.TestAdapter": { + "type": "Direct", + "requested": "[4.2.3, )", + "resolved": "4.2.3", + "contentHash": "oVV/luk0bBghnVvLaw8MwFlD7It0Cx9P2nKobeqIafmTQqFFWY69Wo801dxjeNaLzO/o9WQ84WSK84gXJuubhg==", + "dependencies": { + "MSTest.TestFramework": "4.2.3", + "Microsoft.Testing.Extensions.VSTestBridge": "2.2.3", + "Microsoft.Testing.Platform.MSBuild": "2.2.3" + } + }, + "MSTest.TestFramework": { + "type": "Direct", + "requested": "[4.2.3, )", + "resolved": "4.2.3", + "contentHash": "9zzij59YLh+tf+FRLNqhzHjmdspR91bol+jdQxLlxxTGMAML6LDbvuyXKMGdcrE84+QpKkk6KjTVBC5PBGrDeA==", + "dependencies": { + "MSTest.Analyzers": "4.2.3" + } + }, + "Castle.Core": { + "type": "Transitive", + "resolved": "5.1.1", + "contentHash": "rpYtIczkzGpf+EkZgDr9CClTdemhsrwA/W5hMoPjLkRFnXzH44zDLoovXeKtmxb1ykXK9aJVODSpiJml8CTw2g==", + "dependencies": { + "System.Diagnostics.EventLog": "6.0.0" + } + }, + "EntityFramework": { + "type": "Transitive", + "resolved": "6.5.2", + "contentHash": "8iOcnaKcgkWh35s8EhknnENNwwqvrBJ7jeNbQITbGo1mIeIOhGPfVdNOXZ3Y496T6e6wfXvz0WeXlgMdcgVYSA==", + "dependencies": { + "System.CodeDom": "6.0.0", + "System.ComponentModel.Annotations": "5.0.0", + "System.Configuration.ConfigurationManager": "6.0.1", + "System.Data.SqlClient": "4.8.6" + } + }, + "Microsoft.ApplicationInsights": { + "type": "Transitive", + "resolved": "2.23.0", + "contentHash": "nWArUZTdU7iqZLycLKWe0TDms48KKGE6pONH2terYNa8REXiqixrMOkf1sk5DHGMaUTqONU2YkS4SAXBhLStgw==" + }, + "Microsoft.Testing.Extensions.Telemetry": { + "type": "Transitive", + "resolved": "2.2.3", + "contentHash": "mLdW+JOR3kXYGTdgR/qc/UZBA0r+eCR2k6bUxTcuDj5w9WdIQ7Lol5MBUU7YOSGd9bs9bvhSYWAptgz0YtQqCA==", + "dependencies": { + "Microsoft.ApplicationInsights": "2.23.0", + "Microsoft.Testing.Platform": "2.2.3" + } + }, + "Microsoft.Testing.Extensions.TrxReport.Abstractions": { + "type": "Transitive", + "resolved": "2.2.3", + "contentHash": "hntvxJEkmUAx6C2xXc/PO38DqEQl4rimzOgSvTR1hAMruMid7R4RcXOrzzF33J66gKaN7jRaQ0TMW/nNfaV9jw==", + "dependencies": { + "Microsoft.Testing.Platform": "2.2.3" + } + }, + "Microsoft.Testing.Extensions.VSTestBridge": { + "type": "Transitive", + "resolved": "2.2.3", + "contentHash": "7WlJISO8QKUK+d+WhgnANwy4ACwUrvICnviY/mthPwjZ2gVeDaSUAeBnMy2cxfzZgm8VATtGUDbYzUxsgV2CyQ==", + "dependencies": { + "Microsoft.TestPlatform.ObjectModel": "18.3.0", + "Microsoft.Testing.Extensions.Telemetry": "2.2.3", + "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.2.3", + "Microsoft.Testing.Platform": "2.2.3" + } + }, + "Microsoft.Testing.Platform": { + "type": "Transitive", + "resolved": "2.2.3", + "contentHash": "LhM1/Qoi8Ams5QcD4r3f09CSOono9iQr3NEJQItFtyzWB55nWTgEOsVqXqMWWWIwk3nkPqc+XfnlJmp8xUI5fg==" + }, + "Microsoft.Testing.Platform.MSBuild": { + "type": "Transitive", + "resolved": "2.2.3", + "contentHash": "Q22jJYJLx4srTinsAuoCskqmzjrBJC8YeGJMHHIcrf1dQeHoEZ7wsqDzTlENkMoke2qfufF7U+9u58nlZunH/Q==", + "dependencies": { + "Microsoft.Testing.Platform": "2.2.3" + } + }, + "Microsoft.TestPlatform.ObjectModel": { + "type": "Transitive", + "resolved": "18.3.0", + "contentHash": "AEIEX2aWdPO9XbtR96eBaJxmXRD9vaI9uQ1T/JbPEKlTAZwYx0ZrMzKyULMdh/HH9Sg03kXCoN7LszQ90o6nPQ==" + }, + "Microsoft.Win32.SystemEvents": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "hqTM5628jSsQiv+HGpiq3WKBl2c8v1KZfby2J6Pr7pEPlK9waPdgEO6b8A/+/xn/yZ9ulv8HuqK71ONy2tg67A==" + }, + "MSTest.Analyzers": { + "type": "Transitive", + "resolved": "4.2.3", + "contentHash": "dxOZt8/LWuiox7rugInJoIa5Mmu3pBmXdfaoZOx/mxx8+sUFFpjBXPlWXQXGeWzpkVPNC3x1Jf7rt2h2Zjyvvg==" + }, + "runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "9kyFSIdN3T0qjDQ2R0HRXYIhS3l5psBzQi6qqhdLz+SzFyEy4sVxNOke+yyYv8Cu8rPER12c3RDjLT8wF3WBYQ==", + "dependencies": { + "runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": "4.4.0", + "runtime.win-x64.runtime.native.System.Data.SqlClient.sni": "4.4.0", + "runtime.win-x86.runtime.native.System.Data.SqlClient.sni": "4.4.0" + } + }, + "runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "LbrynESTp3bm5O/+jGL8v0Qg5SJlTV08lpIpFesXjF6uGNMWqFnUQbYBJwZTeua6E/Y7FIM1C54Ey1btLWupdg==" + }, + "runtime.win-x64.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "38ugOfkYJqJoX9g6EYRlZB5U2ZJH51UP8ptxZgdpS07FgOEToV+lS11ouNK2PM12Pr6X/PpT5jK82G3DwH/SxQ==" + }, + "runtime.win-x86.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "YhEdSQUsTx+C8m8Bw7ar5/VesXvCFMItyZF7G1AUY+OM0VPZUOeAVpJ4Wl6fydBGUYZxojTDR3I6Bj/+BPkJNA==" + }, + "Stub.System.Data.SQLite.Core.NetStandard": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "dI7ngiCNgdm+n00nQvFTa+LbHvE9MIQXwMSLRzJI/KAJ7G1WmCachsvfE1CD6xvb3OXJvYYEfv3+S/LHyhN0Rg==" + }, + "System.CodeDom": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "CPc6tWO1LAer3IzfZufDBRL+UZQcj5uS207NHALQzP84Vp/z6wF0Aa0YZImOQY8iStY0A2zI/e3ihKNPfUm8XA==" + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==" + }, + "System.Configuration.ConfigurationManager": { + "type": "Transitive", + "resolved": "6.0.1", + "contentHash": "jXw9MlUu/kRfEU0WyTptAVueupqIeE3/rl0EZDMlf8pcvJnitQ8HeVEp69rZdaStXwTV72boi/Bhw8lOeO+U2w==", + "dependencies": { + "System.Security.Cryptography.ProtectedData": "6.0.0", + "System.Security.Permissions": "6.0.0" + } + }, + "System.Data.SqlClient": { + "type": "Transitive", + "resolved": "4.8.6", + "contentHash": "2Ij/LCaTQRyAi5lAv7UUTV9R2FobC8xN9mE0fXBZohum/xLl8IZVmE98Rq5ugQHjCgTBRKqpXRb4ORulRdA6Ig==", + "dependencies": { + "runtime.native.System.Data.SqlClient.sni": "4.7.0" + } + }, + "System.Data.SQLite": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "JSOJpnBf9goMnxGTJFGCmm6AffxgtpuXNXV5YvWO8UNC2zwd12qkUe5lAbnY+2ohIkIukgIjbvR1RA/sWILv3w==", + "dependencies": { + "System.Data.SQLite.Core": "[1.0.119]", + "System.Data.SQLite.EF6": "[1.0.119]" + } + }, + "System.Data.SQLite.Core": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "bhQB8HVtRA+OOYw8UTD1F1kU+nGJ0/OZvH1JmlVUI4bGvgVEWeX1NcHjA765NvUoRVuCPlt8PrEpZ1thSsk1jg==", + "dependencies": { + "Stub.System.Data.SQLite.Core.NetStandard": "[1.0.119]" + } + }, + "System.Data.SQLite.EF6": { + "type": "Transitive", + "resolved": "1.0.119", + "contentHash": "BwwgCSeA80gsxdXtU7IQEBrN9kQXWQrD11hNYOJZbXBBI1C4r7hA4QhBAalO1nzijXikthGRUADIEMI3nlucLA==", + "dependencies": { + "EntityFramework": "6.4.4" + } + }, + "System.Diagnostics.EventLog": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "lcyUiXTsETK2ALsZrX+nWuHSIQeazhqPphLfaRxzdGaG93+0kELqpgEHtwWOlQe7+jSFnKwaCAgL4kjeZCQJnw==" + }, + "System.Drawing.Common": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "NfuoKUiP2nUWwKZN6twGqXioIe1zVD0RIj2t976A+czLHr2nY454RwwXs6JU9Htc6mwqL6Dn/nEL3dpVf2jOhg==", + "dependencies": { + "Microsoft.Win32.SystemEvents": "6.0.0" + } + }, + "System.Security.Cryptography.ProtectedData": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "rp1gMNEZpvx9vP0JW0oHLxlf8oSiQgtno77Y4PLUBjSiDYoD77Y8uXHr1Ea5XG4/pIKhqAdxZ8v8OTUtqo9PeQ==" + }, + "System.Security.Permissions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "T/uuc7AklkDoxmcJ7LGkyX1CcSviZuLCa4jg3PekfJ7SU0niF0IVTXwUiNVP9DSpzou2PpxJ+eNY2IfDM90ZCg==", + "dependencies": { + "System.Windows.Extensions": "6.0.0" + } + }, + "System.Windows.Extensions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "IXoJOXIqc39AIe+CIR7koBtRGMiCt/LPM3lI+PELtDIy9XdyeSrwXFdWV9dzJ2Awl0paLWUaknLxFQ5HpHZUog==", + "dependencies": { + "System.Drawing.Common": "6.0.0" + } + }, + "sqlite.codefirst": { + "type": "Project", + "dependencies": { + "EntityFramework": "[6.5.2, )" + } + }, + "sqlite.codefirst.netcore.console": { + "type": "Project", + "dependencies": { + "SQLite.CodeFirst": "[1.0.0, )", + "System.Data.SQLite": "[1.0.119, )", + "System.Data.SQLite.EF6": "[1.0.119, )" + } + } + } + } +} \ No newline at end of file diff --git a/SQLite.CodeFirst/packages.lock.json b/SQLite.CodeFirst/packages.lock.json new file mode 100644 index 0000000..9d27514 --- /dev/null +++ b/SQLite.CodeFirst/packages.lock.json @@ -0,0 +1,208 @@ +{ + "version": 1, + "dependencies": { + ".NETFramework,Version=v4.0": { + "EntityFramework": { + "type": "Direct", + "requested": "[6.5.2, )", + "resolved": "6.5.2", + "contentHash": "8iOcnaKcgkWh35s8EhknnENNwwqvrBJ7jeNbQITbGo1mIeIOhGPfVdNOXZ3Y496T6e6wfXvz0WeXlgMdcgVYSA==" + }, + "Microsoft.NETFramework.ReferenceAssemblies": { + "type": "Direct", + "requested": "[1.0.3, )", + "resolved": "1.0.3", + "contentHash": "vUc9Npcs14QsyOD01tnv/m8sQUnGTGOw1BCmKcv77LBJY7OxhJ+zJF7UD/sCL3lYNFuqmQEVlkfS4Quif6FyYg==", + "dependencies": { + "Microsoft.NETFramework.ReferenceAssemblies.net40": "1.0.3" + } + }, + "Microsoft.NETFramework.ReferenceAssemblies.net40": { + "type": "Transitive", + "resolved": "1.0.3", + "contentHash": "3ctXnCpHdoYJNH9ATfXKwckkkdHvHc1Xls12QB9kf1tjh3b+VzxtiwpkZN4GxOawakfH6CJAkqhlDKSiz6Ujbg==" + } + }, + ".NETFramework,Version=v4.5": { + "EntityFramework": { + "type": "Direct", + "requested": "[6.5.2, )", + "resolved": "6.5.2", + "contentHash": "8iOcnaKcgkWh35s8EhknnENNwwqvrBJ7jeNbQITbGo1mIeIOhGPfVdNOXZ3Y496T6e6wfXvz0WeXlgMdcgVYSA==" + }, + "Microsoft.NETFramework.ReferenceAssemblies": { + "type": "Direct", + "requested": "[1.0.3, )", + "resolved": "1.0.3", + "contentHash": "vUc9Npcs14QsyOD01tnv/m8sQUnGTGOw1BCmKcv77LBJY7OxhJ+zJF7UD/sCL3lYNFuqmQEVlkfS4Quif6FyYg==", + "dependencies": { + "Microsoft.NETFramework.ReferenceAssemblies.net45": "1.0.3" + } + }, + "Microsoft.NETFramework.ReferenceAssemblies.net45": { + "type": "Transitive", + "resolved": "1.0.3", + "contentHash": "dcSLNuUX2rfZejsyta2EWZ1W5U6ucbFt697lRg1qiTlTM5ZlYv4uAvuxE6ROy6xLWWhLhOaReCDxkhxcajRYtQ==" + } + }, + ".NETStandard,Version=v2.1": { + "EntityFramework": { + "type": "Direct", + "requested": "[6.5.2, )", + "resolved": "6.5.2", + "contentHash": "8iOcnaKcgkWh35s8EhknnENNwwqvrBJ7jeNbQITbGo1mIeIOhGPfVdNOXZ3Y496T6e6wfXvz0WeXlgMdcgVYSA==", + "dependencies": { + "Microsoft.CSharp": "4.7.0", + "System.CodeDom": "6.0.0", + "System.ComponentModel.Annotations": "5.0.0", + "System.Configuration.ConfigurationManager": "6.0.1", + "System.Data.SqlClient": "4.8.6" + } + }, + "Microsoft.CSharp": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "pTj+D3uJWyN3My70i2Hqo+OXixq3Os2D1nJ2x92FFo6sk8fYS1m1WLNTs0Dc1uPaViH0YvEEwvzddQ7y4rhXmA==" + }, + "Microsoft.Win32.Registry": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "KSrRMb5vNi0CWSGG1++id2ZOs/1QhRqROt+qgbEAdQuGjGrFcl4AOl4/exGPUYz2wUnU42nvJqon1T3U0kPXLA==", + "dependencies": { + "System.Buffers": "4.5.0", + "System.Memory": "4.5.3", + "System.Security.AccessControl": "4.7.0", + "System.Security.Principal.Windows": "4.7.0" + } + }, + "runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "9kyFSIdN3T0qjDQ2R0HRXYIhS3l5psBzQi6qqhdLz+SzFyEy4sVxNOke+yyYv8Cu8rPER12c3RDjLT8wF3WBYQ==", + "dependencies": { + "runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": "4.4.0", + "runtime.win-x64.runtime.native.System.Data.SqlClient.sni": "4.4.0", + "runtime.win-x86.runtime.native.System.Data.SqlClient.sni": "4.4.0" + } + }, + "runtime.win-arm64.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "LbrynESTp3bm5O/+jGL8v0Qg5SJlTV08lpIpFesXjF6uGNMWqFnUQbYBJwZTeua6E/Y7FIM1C54Ey1btLWupdg==" + }, + "runtime.win-x64.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "38ugOfkYJqJoX9g6EYRlZB5U2ZJH51UP8ptxZgdpS07FgOEToV+lS11ouNK2PM12Pr6X/PpT5jK82G3DwH/SxQ==" + }, + "runtime.win-x86.runtime.native.System.Data.SqlClient.sni": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "YhEdSQUsTx+C8m8Bw7ar5/VesXvCFMItyZF7G1AUY+OM0VPZUOeAVpJ4Wl6fydBGUYZxojTDR3I6Bj/+BPkJNA==" + }, + "System.Buffers": { + "type": "Transitive", + "resolved": "4.5.1", + "contentHash": "Rw7ijyl1qqRS0YQD/WycNst8hUUMgrMH4FCn1nNm27M4VxchZ1js3fVjQaANHO5f3sN4isvP4a+Met9Y4YomAg==" + }, + "System.CodeDom": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "CPc6tWO1LAer3IzfZufDBRL+UZQcj5uS207NHALQzP84Vp/z6wF0Aa0YZImOQY8iStY0A2zI/e3ihKNPfUm8XA==" + }, + "System.ComponentModel.Annotations": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "dMkqfy2el8A8/I76n2Hi1oBFEbG1SfxD2l5nhwXV3XjlnOmwxJlQbYpJH4W51odnU9sARCSAgv7S3CyAFMkpYg==" + }, + "System.Configuration.ConfigurationManager": { + "type": "Transitive", + "resolved": "6.0.1", + "contentHash": "jXw9MlUu/kRfEU0WyTptAVueupqIeE3/rl0EZDMlf8pcvJnitQ8HeVEp69rZdaStXwTV72boi/Bhw8lOeO+U2w==", + "dependencies": { + "System.Security.Cryptography.ProtectedData": "6.0.0", + "System.Security.Permissions": "6.0.0" + } + }, + "System.Data.SqlClient": { + "type": "Transitive", + "resolved": "4.8.6", + "contentHash": "2Ij/LCaTQRyAi5lAv7UUTV9R2FobC8xN9mE0fXBZohum/xLl8IZVmE98Rq5ugQHjCgTBRKqpXRb4ORulRdA6Ig==", + "dependencies": { + "Microsoft.Win32.Registry": "4.7.0", + "System.Buffers": "4.5.1", + "System.Diagnostics.DiagnosticSource": "4.7.0", + "System.Memory": "4.5.4", + "System.Security.Principal.Windows": "4.7.0", + "System.Text.Encoding.CodePages": "4.7.0", + "runtime.native.System.Data.SqlClient.sni": "4.7.0" + } + }, + "System.Diagnostics.DiagnosticSource": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "oJjw3uFuVDJiJNbCD8HB4a2p3NYLdt1fiT5OGsPLw+WTOuG0KpP4OXelMmmVKpClueMsit6xOlzy4wNKQFiBLg==", + "dependencies": { + "System.Memory": "4.5.3" + } + }, + "System.Memory": { + "type": "Transitive", + "resolved": "4.5.4", + "contentHash": "1MbJTHS1lZ4bS4FmsJjnuGJOu88ZzTT2rLvrhW7Ygic+pC0NWA+3hgAen0HRdsocuQXCkUTdFn9yHJJhsijDXw==", + "dependencies": { + "System.Buffers": "4.5.1", + "System.Numerics.Vectors": "4.4.0", + "System.Runtime.CompilerServices.Unsafe": "4.5.3" + } + }, + "System.Numerics.Vectors": { + "type": "Transitive", + "resolved": "4.4.0", + "contentHash": "UiLzLW+Lw6HLed1Hcg+8jSRttrbuXv7DANVj0DkL9g6EnnzbL75EB7EWsw5uRbhxd/4YdG8li5XizGWepmG3PQ==" + }, + "System.Runtime.CompilerServices.Unsafe": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "IpU1lcHz8/09yDr9N+Juc7SCgNUz+RohkCQI+KsWKR67XxpFr8Z6c8t1iENCXZuRuNCc4HBwme/MDHNVCwyAKg==" + }, + "System.Security.AccessControl": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "AUADIc0LIEQe7MzC+I0cl0rAT8RrTAKFHl53yHjEUzNVIaUlhFY11vc2ebiVJzVBuOzun6F7FBA+8KAbGTTedQ==", + "dependencies": { + "System.Security.Principal.Windows": "5.0.0" + } + }, + "System.Security.Cryptography.ProtectedData": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "rp1gMNEZpvx9vP0JW0oHLxlf8oSiQgtno77Y4PLUBjSiDYoD77Y8uXHr1Ea5XG4/pIKhqAdxZ8v8OTUtqo9PeQ==", + "dependencies": { + "System.Memory": "4.5.4" + } + }, + "System.Security.Permissions": { + "type": "Transitive", + "resolved": "6.0.0", + "contentHash": "T/uuc7AklkDoxmcJ7LGkyX1CcSviZuLCa4jg3PekfJ7SU0niF0IVTXwUiNVP9DSpzou2PpxJ+eNY2IfDM90ZCg==", + "dependencies": { + "System.Security.AccessControl": "6.0.0" + } + }, + "System.Security.Principal.Windows": { + "type": "Transitive", + "resolved": "5.0.0", + "contentHash": "t0MGLukB5WAVU9bO3MGzvlGnyJPgUlcwerXn1kzBRjwLKixT96XV0Uza41W49gVd8zEMFu9vQEFlv0IOrytICA==" + }, + "System.Text.Encoding.CodePages": { + "type": "Transitive", + "resolved": "4.7.0", + "contentHash": "aeu4FlaUTemuT1qOd1MyU4T516QR4Fy+9yDbwWMPHOHy7U8FD6SgTzdZFO7gHcfAPHtECqInbwklVvUK4RHcNg==", + "dependencies": { + "System.Runtime.CompilerServices.Unsafe": "4.7.0" + } + } + } + } +} \ No newline at end of file From c12edce943a5a756e3e4076c454b046eed9779cf Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:01:44 +0200 Subject: [PATCH 40/56] Replace AppVeyor with GitHub Actions and NuGet trusted publishing - Add a CI workflow (build + test on push/PR to master) and a CD workflow (pack and publish on a v*.*.* tag). Both run on windows-latest because the library targets net40/net45 and the demo targets net48, and restore in locked mode against the committed lock files. - Publish to NuGet with Trusted Publishing (OIDC) via NuGet/login: no long-lived API key, authorized by a trusted-publishing policy on nuget.org that names the cd.yml workflow. The nuget.org account name is provided through the NUGET_USER secret. - Emit a symbol package (snupkg) and attach the package to a generated GitHub Release on tag. - Run tests on Microsoft.Testing.Platform with a TRX report uploaded as a CI artifact (adds the Microsoft.Testing.Extensions.TrxReport extension). - Pin the SDK in global.json so setup-dotnet installs a known version. - Remove the AppVeyor definitions, the now-obsolete empty Version tag, and point the solution folder and README badges at the new workflows. --- .github/workflows/cd.yml | 134 ++++++++++++++++++ .github/workflows/ci.yml | 50 +++++++ README.md | 5 +- .../SQLite.CodeFirst.Test.csproj | 2 + SQLite.CodeFirst.Test/packages.lock.json | 10 ++ SQLite.CodeFirst.slnx | 4 +- SQLite.CodeFirst/SQLite.CodeFirst.csproj | 3 +- ci_appveyor.yml | 23 --- global.json | 4 + release_appveyor.yml | 45 ------ 10 files changed, 206 insertions(+), 74 deletions(-) create mode 100644 .github/workflows/cd.yml create mode 100644 .github/workflows/ci.yml delete mode 100644 ci_appveyor.yml delete mode 100644 release_appveyor.yml diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml new file mode 100644 index 0000000..b0d3492 --- /dev/null +++ b/.github/workflows/cd.yml @@ -0,0 +1,134 @@ +name: CD + +# Builds, tests and packs the NuGet package on a version tag (v1.2.3) or manual run. +# Publishing to NuGet uses Trusted Publishing (OIDC) and runs only on a v*.*.* tag push; a manual +# run packs and uploads the artifact as a dry run without publishing (see the step comments below). + +on: + push: + tags: [ 'v*.*.*' ] + workflow_dispatch: + inputs: + version: + description: 'Package version, e.g. 1.2.3. Defaults to a dev version when omitted.' + required: false + +permissions: + contents: read + +jobs: + pack-publish: + name: Pack & Publish + # Windows is required: the library multi-targets net40/net45 and the demo targets net48, which + # need the .NET Framework reference assemblies / targeting packs available on the Windows runners. + runs-on: windows-latest + timeout-minutes: 15 + permissions: + id-token: write # Required for NuGet Trusted Publishing; without it NuGet/login fails with 403. + contents: write # Required to create the GitHub Release; a job-level block drops inherited defaults. + steps: + - uses: actions/checkout@v6 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + # Install the exact SDK pinned in global.json; Dependabot's dotnet-sdk updater keeps it current. + global-json-file: global.json + # Cache the restored NuGet packages, keyed on the committed lock files. + cache: true + cache-dependency-path: '**/packages.lock.json' + + - name: Resolve version + id: version + shell: bash + # The manual input is read through an env var, not interpolated into the script, so a crafted + # value cannot inject shell. It is then validated as SemVer before anything downstream uses it. + env: + VERSION_INPUT: ${{ github.event.inputs.version }} + run: | + if [[ "${GITHUB_REF}" == refs/tags/v* ]]; then + VERSION="${GITHUB_REF_NAME#v}" + elif [[ -n "${VERSION_INPUT}" ]]; then + VERSION="${VERSION_INPUT}" + if ! [[ "${VERSION}" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then + echo "Invalid version '${VERSION}'; expected SemVer such as 1.2.3 or 1.2.3-rc.1." >&2 + exit 1 + fi + else + VERSION="0.0.0-dev.${GITHUB_RUN_NUMBER}" + fi + echo "version=${VERSION}" >> "$GITHUB_OUTPUT" + echo "Resolved package version: ${VERSION}" + + - name: Restore + # Locked-mode restore fails the build if any packages.lock.json is missing or out of date, so the + # restore is reproducible and a forgotten lock-file update cannot slip through. + run: dotnet restore SQLite.CodeFirst.slnx --locked-mode + + - name: Build + run: dotnet build SQLite.CodeFirst.slnx -c Release --no-restore -p:Version=${{ steps.version.outputs.version }} + + - name: Test + # The test project runs on Microsoft.Testing.Platform (opted in via global.json), so target the + # solution with the native MTP dotnet test syntax. + run: dotnet test --solution SQLite.CodeFirst.slnx -c Release --no-build + + - name: Pack + run: > + dotnet pack SQLite.CodeFirst/SQLite.CodeFirst.csproj -c Release --no-build + -p:Version=${{ steps.version.outputs.version }} + -o ${{ github.workspace }}/artifacts + + - name: Upload package artifact + uses: actions/upload-artifact@v7 + with: + name: nuget-package + path: | + ${{ github.workspace }}/artifacts/*.nupkg + ${{ github.workspace }}/artifacts/*.snupkg + + # --- NuGet publishing via Trusted Publishing (OIDC). --- + # No long-lived API key: NuGet/login swaps the GitHub OIDC token for a short-lived key, authorized + # by the trusted publishing policy on nuget.org (the policy must name this workflow file, cd.yml). + # Gated to tag pushes so a manual run stays a dry run and never pushes the 0.0.0-dev.* version. + # https://learn.microsoft.com/nuget/nuget-org/trusted-publishing + - name: NuGet login (OIDC) + id: nuget-login + if: startsWith(github.ref, 'refs/tags/v') + uses: NuGet/login@v1 + with: + user: ${{ secrets.NUGET_USER }} # nuget.org account/profile name, NOT the email address. + + - name: Publish to NuGet + if: startsWith(github.ref, 'refs/tags/v') + run: > + dotnet nuget push "${{ github.workspace }}/artifacts/*.nupkg" + --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" + --source https://api.nuget.org/v3/index.json + --skip-duplicate + + # --- GitHub Release. --- + # Created only on tag pushes, after a successful NuGet publish, so the Release reflects what was + # actually shipped. Uses the gh CLI (preinstalled on the runner) rather than a third-party action. + # --generate-notes builds the notes from commits/PRs since the previous tag; --verify-tag guards + # against creating a release for a tag the runner cannot see. The .nupkg/.snupkg are attached so + # the package is downloadable straight from the Release page, not just the workflow run. + - name: Create GitHub Release + if: startsWith(github.ref, 'refs/tags/v') + shell: bash + # The tag is passed through an env var rather than interpolated into the script, matching the + # version step above. + env: + GH_TOKEN: ${{ github.token }} + TAG: ${{ github.ref_name }} + run: | + # SemVer pre-release tags carry a hyphen (e.g. v1.2.3-rc.1); mark those as GitHub pre-releases. + prerelease="" + if [[ "${TAG}" == *-* ]]; then prerelease="--prerelease"; fi + gh release create "${TAG}" \ + --title "${TAG}" \ + --generate-notes \ + --verify-tag \ + ${prerelease} \ + "${GITHUB_WORKSPACE}/artifacts/"*.nupkg \ + "${GITHUB_WORKSPACE}/artifacts/"*.snupkg diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..0ed5a17 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,50 @@ +name: CI + +on: + push: + branches: [ master ] + pull_request: + branches: [ master ] + +jobs: + build-test: + name: Build & Test + # Windows is required: the library multi-targets net40/net45 and the demo targets net48, which + # need the .NET Framework reference assemblies / targeting packs available on the Windows runners. + runs-on: windows-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v6 + + - name: Setup .NET + uses: actions/setup-dotnet@v5 + with: + # Install the exact SDK pinned in global.json; Dependabot's dotnet-sdk updater keeps it current. + global-json-file: global.json + # Cache the restored NuGet packages, keyed on the committed lock files. + cache: true + cache-dependency-path: '**/packages.lock.json' + + - name: Restore + # Locked-mode restore fails the build if any packages.lock.json is missing or out of date, so the + # restore is reproducible and a forgotten lock-file update cannot slip through. + run: dotnet restore SQLite.CodeFirst.slnx --locked-mode + + - name: Build + run: dotnet build SQLite.CodeFirst.slnx -c Release --no-restore + + - name: Test + # The test project runs on Microsoft.Testing.Platform (opted in via global.json), so this uses the + # native MTP dotnet test syntax: --solution, and the TRX report flags instead of --logger trx. + run: > + dotnet test --solution SQLite.CodeFirst.slnx -c Release --no-build + --report-trx --report-trx-filename test-results.trx + --results-directory ${{ github.workspace }}/TestResults + + - name: Upload test results + if: always() + uses: actions/upload-artifact@v7 + with: + name: test-results + path: ${{ github.workspace }}/TestResults/*.trx + if-no-files-found: ignore diff --git a/README.md b/README.md index 63d7eb2..9058e78 100644 --- a/README.md +++ b/README.md @@ -1,8 +1,7 @@ # SQLite CodeFirst -**Release Build** [![Build status](https://ci.appveyor.com/api/projects/status/2qavdqctw0ehscm6/branch/master?svg=true)](https://ci.appveyor.com/project/msallin/sqlitecodefirst-nv6vn/branch/master) - -**CI Build** [![Build status](https://ci.appveyor.com/api/projects/status/oc1miog385h801qe?svg=true)](https://ci.appveyor.com/project/msallin/sqlitecodefirst) +[![CI](https://github.com/msallin/SQLiteCodeFirst/actions/workflows/ci.yml/badge.svg)](https://github.com/msallin/SQLiteCodeFirst/actions/workflows/ci.yml) +[![CD](https://github.com/msallin/SQLiteCodeFirst/actions/workflows/cd.yml/badge.svg)](https://github.com/msallin/SQLiteCodeFirst/actions/workflows/cd.yml) Creates a [SQLite Database](https://sqlite.org/) from Code, using [Entity Framework](https://msdn.microsoft.com/en-us/data/ef.aspx) CodeFirst. diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index ece4fdb..0228e1e 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -14,6 +14,8 @@ + + diff --git a/SQLite.CodeFirst.Test/packages.lock.json b/SQLite.CodeFirst.Test/packages.lock.json index 9420ea8..2dccd5e 100644 --- a/SQLite.CodeFirst.Test/packages.lock.json +++ b/SQLite.CodeFirst.Test/packages.lock.json @@ -2,6 +2,16 @@ "version": 1, "dependencies": { "net10.0": { + "Microsoft.Testing.Extensions.TrxReport": { + "type": "Direct", + "requested": "[2.2.3, )", + "resolved": "2.2.3", + "contentHash": "9Hot3ty5ZVWHrW40k2NPfD0dCaPwIxj7j7VjujNYwpYkYw9AdbejPHjGNkL/gvUWorauJf5IkeDoUeIbS7LuUg==", + "dependencies": { + "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.2.3", + "Microsoft.Testing.Platform": "2.2.3" + } + }, "Moq": { "type": "Direct", "requested": "[4.20.72, )", diff --git a/SQLite.CodeFirst.slnx b/SQLite.CodeFirst.slnx index a6f7881..894535d 100644 --- a/SQLite.CodeFirst.slnx +++ b/SQLite.CodeFirst.slnx @@ -1,7 +1,7 @@ - - + + diff --git a/SQLite.CodeFirst/SQLite.CodeFirst.csproj b/SQLite.CodeFirst/SQLite.CodeFirst.csproj index ee45773..a576f4f 100644 --- a/SQLite.CodeFirst/SQLite.CodeFirst.csproj +++ b/SQLite.CodeFirst/SQLite.CodeFirst.csproj @@ -4,12 +4,13 @@ net40;net45;netstandard2.1 Marc Sallin - Creates a SQLite Database from Code, using Entity Framework CodeFirst. This Project ships several IDbInitializer which creates a new SQLite Database, based on your model/code. https://github.com/msallin/SQLiteCodeFirst https://github.com/msallin/SQLiteCodeFirst GitHub true + true + snupkg Apache-2.0 false Copyright (C) Marc Sallin diff --git a/ci_appveyor.yml b/ci_appveyor.yml deleted file mode 100644 index 0e22b91..0000000 --- a/ci_appveyor.yml +++ /dev/null @@ -1,23 +0,0 @@ -version: CI_{branch}_{build} -image: Visual Studio 2022 -skip_tags: true -configuration: -- Release -- Debug -platform: Any CPU -before_build: -- ps: dotnet --version -- ps: dotnet restore -build: - project: SQLite.CodeFirst.slnx - parallel: true - verbosity: normal -artifacts: -- path: SQLite.CodeFirst\bin\Debug\**\SQLite.CodeFirst.dll - name: Debug -- path: SQLite.CodeFirst\bin\Release\**\SQLite.CodeFirst.dll - name: Release -- path: SQLite.CodeFirst\bin\Release\*.nupkg - name: NuPkgDebug -- path: SQLite.CodeFirst\bin\Debug\*.nupkg - name: NuPkgRelease \ No newline at end of file diff --git a/global.json b/global.json index 3140116..70c8f03 100644 --- a/global.json +++ b/global.json @@ -1,4 +1,8 @@ { + "sdk": { + "version": "10.0.300", + "rollForward": "latestMinor" + }, "test": { "runner": "Microsoft.Testing.Platform" } diff --git a/release_appveyor.yml b/release_appveyor.yml deleted file mode 100644 index 9c7ff5b..0000000 --- a/release_appveyor.yml +++ /dev/null @@ -1,45 +0,0 @@ -version: 1.7.0.{build} -image: Visual Studio 2022 -branches: - only: - - master -skip_tags: true -platform: Any CPU -configuration: Release -dotnet_csproj: - patch: true - file: '**\*.csproj' - version: '{version}' - package_version: '{version}' - assembly_version: '{version}' - file_version: '{version}' - informational_version: '{version}' -before_build: -- ps: dotnet --version -- ps: dotnet restore -build: - project: SQLite.CodeFirst.slnx - parallel: true - verbosity: normal -artifacts: -- path: SQLite.CodeFirst\bin - name: Assemblies -- path: SQLite.CodeFirst\bin\Release\*.nupkg - name: NuPkg -deploy: -# Encrypt with https://ci.appveyor.com/tools/encrypt -- provider: NuGet - api_key: - secure: fdOvSLLttfWbXxkmrgNG+jfczNAqx0HOIqYeVhToHGvezVwts758wz+sbGkv2RhZ - on: - branch: master -- provider: GitHub - tag: v$(appveyor_build_version) - release: v$(appveyor_build_version) - description: https://www.nuget.org/packages/SQLite.CodeFirst/ - auth_token: - secure: e3cqaFy9PzI9TAdZJBIDy97Bfbwa7j0EXe2yw7Ev9aJXK0Q+3mnULqb1VU4P7BWR - artifact: Assemblies,NuPkg - draft: true - on: - branch: master \ No newline at end of file From 9799e19109f156b47f017425aeb4e8078c025e15 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:02:10 +0200 Subject: [PATCH 41/56] Add Dependabot configuration Track updates for the .NET SDK (global.json), NuGet packages and GitHub Actions on a weekly schedule. Minor and patch updates are grouped per ecosystem to reduce noise; major updates open their own PR. Updates are proposed as PRs and merged manually. --- .github/dependabot.yml | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/dependabot.yml diff --git a/.github/dependabot.yml b/.github/dependabot.yml new file mode 100644 index 0000000..0905865 --- /dev/null +++ b/.github/dependabot.yml @@ -0,0 +1,36 @@ +# Dependabot keeps the .NET SDK (global.json), NuGet packages and GitHub Actions versions up to date. +# +# Minor and patch updates are grouped into a single PR per ecosystem to cut noise; major updates open +# their own PR so the breaking-change surface stays visible. Updates are proposed as PRs and merged +# manually after the CI "Build & Test" check passes. +version: 2 +updates: + # Bumps the SDK version pinned in global.json, which setup-dotnet installs in CI. The dotnet-sdk + # ecosystem only does version updates (no security updates) and targets global.json files. + - package-ecosystem: dotnet-sdk + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + + - package-ecosystem: nuget + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + groups: + nuget-minor-and-patch: + update-types: + - minor + - patch + + - package-ecosystem: github-actions + directory: "/" + schedule: + interval: weekly + open-pull-requests-limit: 10 + groups: + actions-minor-and-patch: + update-types: + - minor + - patch From 98e02f874ed048749759001f0e9d989f6648f0ae Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:02:49 +0200 Subject: [PATCH 42/56] Fix typos in README gab -> gap, explicit set -> explicitly set, a own -> your own, a additional -> an additional, you may getting -> you may get. --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 9058e78..a077139 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ If you need a specific feature for a commercial project, I am glad to offer a pa ## Project Status -This project was started when there was .NET Full Framework and EF 6. EF 6 does not offer code first for SQLite and this library fills this gab. +This project was started when there was .NET Full Framework and EF 6. EF 6 does not offer code first for SQLite and this library fills this gap. Nowadays there is .NET Core (or now just called .NET) and EF Core. EF Core supports code first and migrations for SQLite. If you use .NET Core 3 or above together with EF Core, there is no need for this library. If you use EF 6 (either with .NET Full Framework or with .NET Core 3 or above), this library is an option for you to get code first for SQLite. @@ -30,10 +30,10 @@ The following features are supported: - PrimaryKey constraint (`Key` annotation, key composites are supported) - ForeignKey constraint (1-n relationships, support for 'Cascade on delete') - Not Null constraint -- Auto increment (An int PrimaryKey will automatically be incremented and you can explicit set the "AUTOINCREMENT" constraint to a PrimaryKey using the Autoincrement-Attribute) +- Auto increment (An int PrimaryKey will automatically be incremented and you can explicitly set the "AUTOINCREMENT" constraint to a PrimaryKey using the Autoincrement-Attribute) - Index (Decorate columns with the `Index` attribute. Indices are automatically created for foreign keys by default. To prevent this you can remove the convention `ForeignKeyIndexConvention`) - Unique constraint (Decorate columns with the `UniqueAttribute`, which is part of this library) -- Collate constraint (Decorate columns with the `CollateAttribute`, which is part of this library. Use `CollationFunction.Custom` to specify a own collation function.) +- Collate constraint (Decorate columns with the `CollateAttribute`, which is part of this library. Use `CollationFunction.Custom` to specify your own collation function.) - Default collation (pass an instance of Collation as constructor parameter for an initializer to specify a default collation). - SQL default value (Decorate columns with the `SqlDefaultValueAttribute`, which is part of this library) @@ -79,7 +79,7 @@ public class MyDbContext : DbContext } ``` -Notice that the `SqliteDropCreateDatabaseWhenModelChanges<>` initializer will create a additional table in your database. +Notice that the `SqliteDropCreateDatabaseWhenModelChanges<>` initializer will create an additional table in your database. This table is used to store some information to detect model changes. If you want to use an own entity/table you have to implement the `IHistory` interface and pass the type of your entity as parameter to the constructor of the initializer. @@ -176,7 +176,7 @@ You will find an extensive usage of the composite pattern. ## Hints -If you try to reinstall the NuGet-Packages (e.g. if you want to downgrade to .NET 4.0), the app.config will be overwritten and you may getting an exception when you try to run the console project. +If you try to reinstall the NuGet-Packages (e.g. if you want to downgrade to .NET 4.0), the app.config will be overwritten and you may get an exception when you try to run the console project. In this case please check the following issue: ## Recognition From eb35aba3c61bd5a71235f676a46b21bc6b2d1307 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:06:20 +0200 Subject: [PATCH 43/56] Note .NET 10 support in README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index a077139..9bb4fef 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ You can use the SQLite CodeFirst in projects that target the following framework - .NET 4.0 (uses net40) - .NET 4.5-4.8 (uses net45) - .NET Core 3.0-3.1 (uses netstandard2.1) -- .NET 5-8 (uses netstandard2.1) +- .NET 5 and later, including .NET 10 (uses netstandard2.1) ## How to use From f7ed6b9e80c3b0330c706b9c0d7c1d5689bf17b4 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:20:46 +0200 Subject: [PATCH 44/56] Fix NuGet publish and release steps on Windows runner dotnet nuget push and gh release create relied on shell glob expansion that works on the Ubuntu reference but not on the windows-latest runner this repo needs (PowerShell does not expand *.nupkg for dotnet, and bash mangles the backslashes in the workspace path). Resolve the package and release assets explicitly with Get-ChildItem in PowerShell instead. --- .github/workflows/cd.yml | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index b0d3492..1f3c728 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -101,11 +101,16 @@ jobs: - name: Publish to NuGet if: startsWith(github.ref, 'refs/tags/v') - run: > - dotnet nuget push "${{ github.workspace }}/artifacts/*.nupkg" - --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" - --source https://api.nuget.org/v3/index.json - --skip-duplicate + shell: pwsh + # Resolve the package explicitly: on the Windows runner the default PowerShell shell does not + # expand a "*.nupkg" wildcard for dotnet, so a literal glob path is passed through and not found. + # Pushing the .nupkg also pushes the sibling .snupkg symbol package to nuget.org automatically. + run: | + $package = Get-ChildItem -Path "${{ github.workspace }}/artifacts/*.nupkg" | Select-Object -First 1 + dotnet nuget push $package.FullName ` + --api-key "${{ steps.nuget-login.outputs.NUGET_API_KEY }}" ` + --source https://api.nuget.org/v3/index.json ` + --skip-duplicate # --- GitHub Release. --- # Created only on tag pushes, after a successful NuGet publish, so the Release reflects what was @@ -115,20 +120,17 @@ jobs: # the package is downloadable straight from the Release page, not just the workflow run. - name: Create GitHub Release if: startsWith(github.ref, 'refs/tags/v') - shell: bash + shell: pwsh # The tag is passed through an env var rather than interpolated into the script, matching the - # version step above. + # version step above. Assets are resolved with Get-ChildItem so the wildcards expand on the + # Windows runner (bash would mangle the backslashes in the workspace path). env: GH_TOKEN: ${{ github.token }} TAG: ${{ github.ref_name }} run: | + $assets = Get-ChildItem -Path "${{ github.workspace }}/artifacts/*.nupkg", "${{ github.workspace }}/artifacts/*.snupkg" | ForEach-Object { $_.FullName } # SemVer pre-release tags carry a hyphen (e.g. v1.2.3-rc.1); mark those as GitHub pre-releases. - prerelease="" - if [[ "${TAG}" == *-* ]]; then prerelease="--prerelease"; fi - gh release create "${TAG}" \ - --title "${TAG}" \ - --generate-notes \ - --verify-tag \ - ${prerelease} \ - "${GITHUB_WORKSPACE}/artifacts/"*.nupkg \ - "${GITHUB_WORKSPACE}/artifacts/"*.snupkg + $ghArgs = @($env:TAG, '--title', $env:TAG, '--generate-notes', '--verify-tag') + if ($env:TAG -like '*-*') { $ghArgs += '--prerelease' } + $ghArgs += $assets + gh release create $ghArgs From 81f12d563a90f0bf89b27e0328d6238227331316 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Tue, 16 Jun 2026 00:10:53 +0000 Subject: [PATCH 45/56] Bump dotnet-sdk from 10.0.300 to 10.0.301 Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.300 to 10.0.301. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](https://github.com/dotnet/sdk/compare/v10.0.300...v10.0.301) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 10.0.301 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index 70c8f03..f272fe7 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.300", + "version": "10.0.301", "rollForward": "latestMinor" }, "test": { From 82c1e25569fe20e066d44738022cbec8ac31538b Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:48:33 +0200 Subject: [PATCH 46/56] feat: support ON UPDATE CASCADE via CascadeOnUpdate attribute Entity Framework has no concept of update-cascade (it assumes immutable keys), so the generated DDL only ever emitted ON DELETE CASCADE. Neither ForeignKeyAttribute nor the fluent API can express ON UPDATE CASCADE. Add an opt-in CascadeOnUpdateAttribute placed on the dependent foreign key property. It is registered as a column annotation, survives the EF model build, and is read back from the store model during SQL generation to append the ON UPDATE CASCADE clause to the foreign key constraint. Co-Authored-By: Claude Opus 4.8 (1M context) --- README.md | 3 +- .../IntegrationTests/CascadeOnUpdateTest.cs | 125 ++++++++++++++++++ .../Statement/ForeignKeyStatementTest.cs | 31 +++++ .../Builder/ForeignKeyStatementBuilder.cs | 3 +- .../Internal/Statement/ForeignKeyStatement.cs | 6 + .../Internal/Utility/SqliteAssociationType.cs | 9 ++ .../Attributes/CascadeOnUpdateAttribute.cs | 28 ++++ .../DbInitializers/SqliteInitializerBase.cs | 1 + 8 files changed, 204 insertions(+), 2 deletions(-) create mode 100644 SQLite.CodeFirst.Test/IntegrationTests/CascadeOnUpdateTest.cs create mode 100644 SQLite.CodeFirst/Public/Attributes/CascadeOnUpdateAttribute.cs diff --git a/README.md b/README.md index 9bb4fef..a6b9367 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The following features are supported: - Tables from classes (supported annotations: `Table`) - Columns from properties (supported annotations: `Column`, `Key`, `MaxLength`, `Required`, `NotMapped`, `DatabaseGenerated`, `Index`) - PrimaryKey constraint (`Key` annotation, key composites are supported) -- ForeignKey constraint (1-n relationships, support for 'Cascade on delete') +- ForeignKey constraint (1-n relationships, support for 'Cascade on delete' and 'Cascade on update') - Not Null constraint - Auto increment (An int PrimaryKey will automatically be incremented and you can explicitly set the "AUTOINCREMENT" constraint to a PrimaryKey using the Autoincrement-Attribute) - Index (Decorate columns with the `Index` attribute. Indices are automatically created for foreign keys by default. To prevent this you can remove the convention `ForeignKeyIndexConvention`) @@ -36,6 +36,7 @@ The following features are supported: - Collate constraint (Decorate columns with the `CollateAttribute`, which is part of this library. Use `CollationFunction.Custom` to specify your own collation function.) - Default collation (pass an instance of Collation as constructor parameter for an initializer to specify a default collation). - SQL default value (Decorate columns with the `SqlDefaultValueAttribute`, which is part of this library) +- Cascade on update (Decorate the foreign key property with the `CascadeOnUpdateAttribute`, which is part of this library. Entity Framework cannot express `ON UPDATE CASCADE`, so this opt-in attribute must be placed on the dependent foreign key property, e.g. `TeamId`, not on the navigation property. It requires an explicit foreign key property.) ## Install diff --git a/SQLite.CodeFirst.Test/IntegrationTests/CascadeOnUpdateTest.cs b/SQLite.CodeFirst.Test/IntegrationTests/CascadeOnUpdateTest.cs new file mode 100644 index 0000000..1e7b45c --- /dev/null +++ b/SQLite.CodeFirst.Test/IntegrationTests/CascadeOnUpdateTest.cs @@ -0,0 +1,125 @@ +using System.Collections.Generic; +using System.Data.Common; +using System.Data.Entity; +using System.Data.Entity.Infrastructure; +using System.Data.SQLite; +using System.Linq; +using Microsoft.VisualStudio.TestTools.UnitTesting; + +namespace SQLite.CodeFirst.Test.IntegrationTests +{ + /// + /// Verifies that the placed on a foreign key property + /// results in 'ON UPDATE CASCADE' being emitted for the corresponding foreign key constraint. + /// This exercises the full pipeline: the attribute is registered as a column annotation, survives + /// the EF model build and is read back from the store model when the SQL is generated. + /// + [TestClass] + public class CascadeOnUpdateTest + { + private static string generatedSql; + + [TestMethod] + public void CascadeOnUpdateAttributeEmitsOnUpdateCascade() + { + using (DbConnection connection = new SQLiteConnection("FullUri=file::memory:")) + { + // This is important! Else the in memory database will not work. + connection.Open(); + + using (var context = new CascadeDbContext(connection)) + { + // Touching the set forces the initializer (and therefore the SQL generation) to run. + context.Set().FirstOrDefault(); + } + } + + // Decorated FK with cascade-on-delete: both keywords, delete before update. + StringAssert.Contains(generatedSql, "FOREIGN KEY ([CustomerId]) REFERENCES \"Customers\"([Id]) ON DELETE CASCADE ON UPDATE CASCADE"); + + // Decorated FK without cascade-on-delete: only the update keyword. + StringAssert.Contains(generatedSql, "FOREIGN KEY ([WarehouseId]) REFERENCES \"Warehouses\"([Id]) ON UPDATE CASCADE"); + + // Undecorated FK: no cascade keyword at all. + Assert.IsFalse(generatedSql.Contains("[RegionId]) REFERENCES \"Regions\"([Id]) ON"), + "The foreign key without the attribute must not emit any cascade clause."); + } + + private class Customer + { + public int Id { get; set; } + } + + private class Warehouse + { + public int Id { get; set; } + } + + private class Region + { + public int Id { get; set; } + } + + private class Order + { + public int Id { get; set; } + + [CascadeOnUpdate] + public int CustomerId { get; set; } + public Customer Customer { get; set; } + + [CascadeOnUpdate] + public int? WarehouseId { get; set; } + public Warehouse Warehouse { get; set; } + + public int? RegionId { get; set; } + public Region Region { get; set; } + } + + private class CascadeDbContext : DbContext + { + public CascadeDbContext(DbConnection connection) + : base(connection, false) + { + } + + protected override void OnModelCreating(DbModelBuilder modelBuilder) + { + modelBuilder.Entity() + .HasRequired(o => o.Customer) + .WithMany() + .HasForeignKey(o => o.CustomerId) + .WillCascadeOnDelete(true); + + modelBuilder.Entity() + .HasOptional(o => o.Warehouse) + .WithMany() + .HasForeignKey(o => o.WarehouseId) + .WillCascadeOnDelete(false); + + modelBuilder.Entity() + .HasOptional(o => o.Region) + .WithMany() + .HasForeignKey(o => o.RegionId) + .WillCascadeOnDelete(false); + + Database.SetInitializer(new CaptureInitializer(modelBuilder)); + } + } + + private class CaptureInitializer : SqliteInitializerBase + { + public CaptureInitializer(DbModelBuilder modelBuilder) + : base(modelBuilder) + { + } + + public override void InitializeDatabase(CascadeDbContext context) + { + DbModel model = ModelBuilder.Build(context.Database.Connection); + generatedSql = new SqliteSqlGenerator().Generate(model.StoreModel); + base.InitializeDatabase(context); + } + } + } +} diff --git a/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs b/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs index 0a8ac9f..65dd2d7 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Statement/ForeignKeyStatementTest.cs @@ -37,6 +37,37 @@ public void CreateStatementOneForeignKeyCascadeDeleteTest() Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE", output); } + [TestMethod] + public void CreateStatementOneForeignKeyCascadeUpdateTest() + { + var foreignKeyStatement = new ForeignKeyStatement + { + CascadeUpdate = true, + ForeignKey = new List { "dummyForeignKey1" }, + ForeignPrimaryKey = new List { "dummForeignPrimaryKey1" }, + ForeignTable = "dummyForeignTable" + }; + + string output = foreignKeyStatement.CreateStatement(); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON UPDATE CASCADE", output); + } + + [TestMethod] + public void CreateStatementOneForeignKeyCascadeDeleteAndUpdateTest() + { + var foreignKeyStatement = new ForeignKeyStatement + { + CascadeDelete = true, + CascadeUpdate = true, + ForeignKey = new List { "dummyForeignKey1" }, + ForeignPrimaryKey = new List { "dummForeignPrimaryKey1" }, + ForeignTable = "dummyForeignTable" + }; + + string output = foreignKeyStatement.CreateStatement(); + Assert.AreEqual("FOREIGN KEY ([dummyForeignKey1]) REFERENCES dummyForeignTable([dummForeignPrimaryKey1]) ON DELETE CASCADE ON UPDATE CASCADE", output); + } + [TestMethod] public void CreateStatementTwoForeignKeyTest() { diff --git a/SQLite.CodeFirst/Internal/Builder/ForeignKeyStatementBuilder.cs b/SQLite.CodeFirst/Internal/Builder/ForeignKeyStatementBuilder.cs index e5fd81a..0dd595c 100644 --- a/SQLite.CodeFirst/Internal/Builder/ForeignKeyStatementBuilder.cs +++ b/SQLite.CodeFirst/Internal/Builder/ForeignKeyStatementBuilder.cs @@ -29,7 +29,8 @@ private IEnumerable GetForeignKeyStatements() ForeignKey = associationType.ForeignKey, ForeignTable = associationType.FromTableName, ForeignPrimaryKey = associationType.ForeignPrimaryKey, - CascadeDelete = associationType.CascadeDelete + CascadeDelete = associationType.CascadeDelete, + CascadeUpdate = associationType.CascadeUpdate }; } } diff --git a/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs b/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs index 58b4974..6b862a7 100644 --- a/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs +++ b/SQLite.CodeFirst/Internal/Statement/ForeignKeyStatement.cs @@ -9,11 +9,13 @@ internal class ForeignKeyStatement : IStatement { private const string Template = "FOREIGN KEY ({foreign-key}) REFERENCES {referenced-table}({referenced-id})"; private const string CascadeDeleteStatement = "ON DELETE CASCADE"; + private const string CascadeUpdateStatement = "ON UPDATE CASCADE"; public IEnumerable ForeignKey { get; set; } public string ForeignTable { get; set; } public IEnumerable ForeignPrimaryKey { get; set; } public bool CascadeDelete { get; set; } + public bool CascadeUpdate { get; set; } public string CreateStatement() { @@ -25,6 +27,10 @@ public string CreateStatement() { sb.Append(" " + CascadeDeleteStatement); } + if (CascadeUpdate) + { + sb.Append(" " + CascadeUpdateStatement); + } return sb.ToString(); } diff --git a/SQLite.CodeFirst/Internal/Utility/SqliteAssociationType.cs b/SQLite.CodeFirst/Internal/Utility/SqliteAssociationType.cs index 6ab4f49..7532614 100644 --- a/SQLite.CodeFirst/Internal/Utility/SqliteAssociationType.cs +++ b/SQLite.CodeFirst/Internal/Utility/SqliteAssociationType.cs @@ -2,6 +2,7 @@ using System.Data.Entity.Core.Metadata.Edm; using System.Linq; using SQLite.CodeFirst.Builder.NameCreators; +using SQLite.CodeFirst.Extensions; namespace SQLite.CodeFirst.Utility { @@ -30,6 +31,13 @@ public SqliteAssociationType(AssociationType associationType, EntityContainer co ForeignKey = associationType.Constraint.ToProperties.Select(x => x.Name); ForeignPrimaryKey = associationType.Constraint.FromProperties.Select(x => x.Name); CascadeDelete = associationType.Constraint.FromRole.DeleteBehavior == OperationAction.Cascade; + + // EF has no notion of update-cascade, so it is opt-in via the CascadeOnUpdateAttribute placed on the + // dependent foreign key property. The attribute is registered as a column annotation and therefore + // available on the store model foreign key columns (the constraint's ToProperties). + CascadeUpdate = associationType.Constraint.ToProperties + .Select(property => property.GetCustomAnnotation()) + .Any(attribute => attribute != null && attribute.CanCascade); } private static bool IsSelfReferencing(AssociationType associationType) @@ -47,5 +55,6 @@ private static bool IsSelfReferencing(AssociationType associationType) public string ToTableName { get; } public IEnumerable ForeignPrimaryKey { get; } public bool CascadeDelete { get; } + public bool CascadeUpdate { get; } } } \ No newline at end of file diff --git a/SQLite.CodeFirst/Public/Attributes/CascadeOnUpdateAttribute.cs b/SQLite.CodeFirst/Public/Attributes/CascadeOnUpdateAttribute.cs new file mode 100644 index 0000000..5870ccf --- /dev/null +++ b/SQLite.CodeFirst/Public/Attributes/CascadeOnUpdateAttribute.cs @@ -0,0 +1,28 @@ +using System; + +namespace SQLite.CodeFirst +{ + /// + /// Adds 'ON UPDATE CASCADE' to the foreign key constraint of the relationship the decorated property belongs to. + /// Entity Framework has no concept of update-cascade (it assumes primary keys are immutable), so neither the + /// nor the fluent API can express it. + /// This opt-in attribute is the only way to emit the keyword. + /// Place it on the dependent foreign key property (e.g. the 'TeamId' property), not on the navigation property (e.g. 'Team'). + /// Requires an explicit foreign key property; relationships with a shadow foreign key column cannot be decorated. + /// + [AttributeUsage(AttributeTargets.Property)] + public sealed class CascadeOnUpdateAttribute : Attribute + { + public CascadeOnUpdateAttribute() + { + CanCascade = true; + } + + public CascadeOnUpdateAttribute(bool canCascade) + { + CanCascade = canCascade; + } + + public bool CanCascade { get; } + } +} diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs index 1309b1f..4e20b33 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteInitializerBase.cs @@ -40,6 +40,7 @@ protected SqliteInitializerBase(DbModelBuilder modelBuilder, Collation defaultCo modelBuilder.RegisterAttributeAsColumnAnnotation(); modelBuilder.RegisterAttributeAsColumnAnnotation(); modelBuilder.RegisterAttributeAsColumnAnnotation(); + modelBuilder.RegisterAttributeAsColumnAnnotation(); // By default there is a 'ForeignKeyIndexConvention' but it can be removed. // And there is no "Contains" and no way to enumerate the ConventionsCollection. From 6c8e098baf3ecc1e9eb042f8af410e90838132c5 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:47:19 +0200 Subject: [PATCH 47/56] feat: expose default collation through the public initializers SqliteInitializerBase already accepts a default Collation and feeds it into SQL generation, but none of the three concrete initializers forwarded it, so the documented "default collation" feature was unreachable without subclassing. Add constructor overloads that pass a Collation to the base class. --- .../InitializerDefaultCollationTest.cs | 64 +++++++++++++++++++ .../SqliteCreateDatabaseIfNotExists.cs | 23 ++++++- .../SqliteDropCreateDatabaseAlways.cs | 11 +++- ...qliteDropCreateDatabaseWhenModelChanges.cs | 28 ++++++-- 4 files changed, 117 insertions(+), 9 deletions(-) create mode 100644 SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs diff --git a/SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs b/SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs new file mode 100644 index 0000000..256b323 --- /dev/null +++ b/SQLite.CodeFirst.Test/UnitTests/DbInitializers/InitializerDefaultCollationTest.cs @@ -0,0 +1,64 @@ +using System.Data.Entity; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SQLite.CodeFirst.NetCore.Console; + +namespace SQLite.CodeFirst.Test.UnitTests.DbInitializers +{ + /// + /// Verifies that the public initializers forward an explicitly supplied default + /// to the base class, which is what feeds it into the SQL generation. + /// Without this the documented "default collation" feature is unreachable through the shipped initializers. + /// + [TestClass] + public class InitializerDefaultCollationTest + { + private static readonly Collation Collation = new Collation(CollationFunction.RTrim); + + private static DbModelBuilder NewModelBuilder() + { + return new DbModelBuilder(); + } + + [TestMethod] + public void SqliteCreateDatabaseIfNotExists_ForwardsDefaultCollation() + { + var initializer = new SqliteCreateDatabaseIfNotExists(NewModelBuilder(), Collation); + Assert.AreSame(Collation, initializer.DefaultCollation); + } + + [TestMethod] + public void SqliteCreateDatabaseIfNotExists_WithNullByteFlag_ForwardsDefaultCollation() + { + var initializer = new SqliteCreateDatabaseIfNotExists(NewModelBuilder(), true, Collation); + Assert.AreSame(Collation, initializer.DefaultCollation); + } + + [TestMethod] + public void SqliteDropCreateDatabaseAlways_ForwardsDefaultCollation() + { + var initializer = new SqliteDropCreateDatabaseAlways(NewModelBuilder(), Collation); + Assert.AreSame(Collation, initializer.DefaultCollation); + } + + [TestMethod] + public void SqliteDropCreateDatabaseWhenModelChanges_ForwardsDefaultCollation() + { + var initializer = new SqliteDropCreateDatabaseWhenModelChanges(NewModelBuilder(), Collation); + Assert.AreSame(Collation, initializer.DefaultCollation); + } + + [TestMethod] + public void SqliteDropCreateDatabaseWhenModelChanges_WithHistoryType_ForwardsDefaultCollation() + { + var initializer = new SqliteDropCreateDatabaseWhenModelChanges(NewModelBuilder(), typeof(History), Collation); + Assert.AreSame(Collation, initializer.DefaultCollation); + } + + [TestMethod] + public void Initializer_WithoutCollation_HasNullDefaultCollation() + { + var initializer = new SqliteDropCreateDatabaseAlways(NewModelBuilder()); + Assert.IsNull(initializer.DefaultCollation); + } + } +} diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs index c572be6..6bfd7dd 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteCreateDatabaseIfNotExists.cs @@ -19,7 +19,16 @@ public class SqliteCreateDatabaseIfNotExists : SqliteInitializerBase /// The model builder. public SqliteCreateDatabaseIfNotExists(DbModelBuilder modelBuilder) - : this(modelBuilder, false) + : this(modelBuilder, false, null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The model builder. + /// The default collation applied to all string columns. Explicit s take precedence. + public SqliteCreateDatabaseIfNotExists(DbModelBuilder modelBuilder, Collation defaultCollation) + : this(modelBuilder, false, defaultCollation) { } /// @@ -28,7 +37,17 @@ public SqliteCreateDatabaseIfNotExists(DbModelBuilder modelBuilder) /// The model builder. /// if set to true a null byte database file is treated like the database does not exist. public SqliteCreateDatabaseIfNotExists(DbModelBuilder modelBuilder, bool nullByteFileMeansNotExisting) - : base(modelBuilder) + : this(modelBuilder, nullByteFileMeansNotExisting, null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The model builder. + /// if set to true a null byte database file is treated like the database does not exist. + /// The default collation applied to all string columns. Explicit s take precedence. + public SqliteCreateDatabaseIfNotExists(DbModelBuilder modelBuilder, bool nullByteFileMeansNotExisting, Collation defaultCollation) + : base(modelBuilder, defaultCollation) { this.nullByteFileMeansNotExisting = nullByteFileMeansNotExisting; } diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs index 3154835..fb73aee 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseAlways.cs @@ -17,7 +17,16 @@ public class SqliteDropCreateDatabaseAlways : SqliteInitializerBase /// The model builder. public SqliteDropCreateDatabaseAlways(DbModelBuilder modelBuilder) - : base(modelBuilder) + : this(modelBuilder, null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The model builder. + /// The default collation applied to all string columns. Explicit s take precedence. + public SqliteDropCreateDatabaseAlways(DbModelBuilder modelBuilder, Collation defaultCollation) + : base(modelBuilder, defaultCollation) { } /// diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index f8029fc..7e6d834 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -34,11 +34,17 @@ public class SqliteDropCreateDatabaseWhenModelChanges : SqliteInitiali /// /// The model builder. public SqliteDropCreateDatabaseWhenModelChanges(DbModelBuilder modelBuilder) - : base(modelBuilder) - { - historyEntityType = typeof(History); - ConfigureHistoryEntity(); - } + : this(modelBuilder, typeof(History), null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The model builder. + /// The default collation applied to all string columns. Explicit s take precedence. + public SqliteDropCreateDatabaseWhenModelChanges(DbModelBuilder modelBuilder, Collation defaultCollation) + : this(modelBuilder, typeof(History), defaultCollation) + { } /// /// Initializes a new instance of the class. @@ -46,7 +52,17 @@ public SqliteDropCreateDatabaseWhenModelChanges(DbModelBuilder modelBuilder) /// The model builder. /// Type of the history entity (must implement and provide an parameterless constructor). public SqliteDropCreateDatabaseWhenModelChanges(DbModelBuilder modelBuilder, Type historyEntityType) - : base(modelBuilder) + : this(modelBuilder, historyEntityType, null) + { } + + /// + /// Initializes a new instance of the class. + /// + /// The model builder. + /// Type of the history entity (must implement and provide an parameterless constructor). + /// The default collation applied to all string columns. Explicit s take precedence. + public SqliteDropCreateDatabaseWhenModelChanges(DbModelBuilder modelBuilder, Type historyEntityType, Collation defaultCollation) + : base(modelBuilder, defaultCollation) { this.historyEntityType = historyEntityType; ConfigureHistoryEntity(); From 068a19cb46029fa11310bbf477aa80cf865b7975 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:49:32 +0200 Subject: [PATCH 48/56] fix: scope history record lookup by context key SqliteDropCreateDatabaseWhenModelChanges stores the context name on each history record and documents that a database may be shared by several contexts, but GetHistoryRecord selected with SingleOrDefault and no Context filter. On a shared history table that matches multiple records: IsSameModel swallows the resulting exception and reports a model change, while SaveHistory throws. Look the record up by context.GetType().FullName, matching what SaveHistory writes. --- .../Utility/HistoryRecordSelectorTest.cs | 56 +++++++++++++++++++ .../Internal/Utility/HistoryRecordSelector.cs | 19 +++++++ ...qliteDropCreateDatabaseWhenModelChanges.cs | 6 +- 3 files changed, 80 insertions(+), 1 deletion(-) create mode 100644 SQLite.CodeFirst.Test/UnitTests/Utility/HistoryRecordSelectorTest.cs create mode 100644 SQLite.CodeFirst/Internal/Utility/HistoryRecordSelector.cs diff --git a/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryRecordSelectorTest.cs b/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryRecordSelectorTest.cs new file mode 100644 index 0000000..b53a240 --- /dev/null +++ b/SQLite.CodeFirst.Test/UnitTests/Utility/HistoryRecordSelectorTest.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; +using Microsoft.VisualStudio.TestTools.UnitTesting; +using SQLite.CodeFirst.Utility; + +namespace SQLite.CodeFirst.Test.UnitTests.Utility +{ + [TestClass] + public class HistoryRecordSelectorTest + { + private static IHistory Record(string context) + { + return new History { Context = context, Hash = "hash-" + context }; + } + + [TestMethod] + public void SelectForContext_ReturnsRecordForGivenContext() + { + var records = new List { Record("ContextA"), Record("ContextB") }; + + IHistory result = HistoryRecordSelector.SelectForContext(records, "ContextB"); + + Assert.IsNotNull(result); + Assert.AreEqual("ContextB", result.Context); + } + + [TestMethod] + public void SelectForContext_ReturnsNull_WhenNoRecordMatches() + { + var records = new List { Record("ContextA") }; + + IHistory result = HistoryRecordSelector.SelectForContext(records, "ContextB"); + + Assert.IsNull(result); + } + + [TestMethod] + public void SelectForContext_ReturnsNull_WhenEmpty() + { + IHistory result = HistoryRecordSelector.SelectForContext(new List(), "ContextA"); + + Assert.IsNull(result); + } + + [TestMethod] + public void SelectForContext_Throws_WhenMultipleRecordsShareContext() + { + // One record per context is an invariant maintained by SaveHistory. If it is ever + // violated, surfacing it is better than silently picking an arbitrary record. + var records = new List { Record("ContextA"), Record("ContextA") }; + + Assert.ThrowsExactly( + () => HistoryRecordSelector.SelectForContext(records, "ContextA")); + } + } +} diff --git a/SQLite.CodeFirst/Internal/Utility/HistoryRecordSelector.cs b/SQLite.CodeFirst/Internal/Utility/HistoryRecordSelector.cs new file mode 100644 index 0000000..9621370 --- /dev/null +++ b/SQLite.CodeFirst/Internal/Utility/HistoryRecordSelector.cs @@ -0,0 +1,19 @@ +using System.Collections.Generic; +using System.Linq; + +namespace SQLite.CodeFirst.Utility +{ + /// + /// Selects the history record that belongs to a specific context from the history table. + /// A database can be shared by multiple contexts, so the lookup must be scoped by the context + /// key. Selecting without that scope would return more than one record on a shared database and + /// make the underlying throw. + /// + internal static class HistoryRecordSelector + { + public static IHistory SelectForContext(IEnumerable records, string contextKey) + { + return records.SingleOrDefault(record => record.Context == contextKey); + } + } +} diff --git a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs index 7e6d834..dbe050c 100644 --- a/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs +++ b/SQLite.CodeFirst/Public/DbInitializers/SqliteDropCreateDatabaseWhenModelChanges.cs @@ -175,7 +175,11 @@ private IHistory GetHistoryRecord(TContext context) // in order to be supported by .NET 4.0. DbQuery dbQuery = context.Set(historyEntityType).AsNoTracking(); IEnumerable records = Enumerable.Cast(dbQuery); - return records.SingleOrDefault(); + + // A database can be shared by several contexts, so the record must be looked up by the + // context key that SaveHistory writes. An unscoped lookup would match every context's + // record and throw on a shared history table. + return HistoryRecordSelector.SelectForContext(records, context.GetType().FullName); } private string GetHashFromModel(DbConnection connection) From c6cae4142c9de69eeb2dd360b24668c4f9787ba5 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:51:01 +0200 Subject: [PATCH 49/56] fix: preserve connection string values containing equals signs ParseConnectionString split each pair on every '=' and kept only the second segment, truncating any Data Source value that contains '=' at the first one. Split on the first '=' only. Also assign via the dictionary indexer (last value wins) instead of Add, so a repeated key no longer throws. --- .../Utility/ConnectionStringParserTest.cs | 28 +++++++++++++++++++ .../Utility/ConnectionStringParser.cs | 7 +++-- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/SQLite.CodeFirst.Test/UnitTests/Utility/ConnectionStringParserTest.cs b/SQLite.CodeFirst.Test/UnitTests/Utility/ConnectionStringParserTest.cs index 998f5c8..d6e6238 100644 --- a/SQLite.CodeFirst.Test/UnitTests/Utility/ConnectionStringParserTest.cs +++ b/SQLite.CodeFirst.Test/UnitTests/Utility/ConnectionStringParserTest.cs @@ -106,5 +106,33 @@ public void GetDataSource_ReturnsCorrectDataSource_RemovesQuotationMark() // Assert Assert.AreEqual(@".\db\footballDb\footballDb.sqlite", result); } + + [TestMethod] + public void GetDataSource_ReturnsCorrectDataSource_WhenValueContainsEqualsSign() + { + // Arrange + string connectionString = @"data source=.\db\foo=bar\footballDb.sqlite;foreign keys=true"; + + + // Act + string result = ConnectionStringParser.GetDataSource(connectionString); + + // Assert + Assert.AreEqual(@".\db\foo=bar\footballDb.sqlite", result); + } + + [TestMethod] + public void GetDataSource_ReturnsLastValue_WhenKeyIsRepeated() + { + // Arrange + string connectionString = @"data source=first.sqlite;data source=second.sqlite"; + + + // Act + string result = ConnectionStringParser.GetDataSource(connectionString); + + // Assert + Assert.AreEqual(@"second.sqlite", result); + } } } diff --git a/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs b/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs index 02c2c21..a146dfb 100644 --- a/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs +++ b/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs @@ -42,10 +42,13 @@ private static IDictionary ParseConnectionString(string connecti IDictionary keyValuePairDictionary = new Dictionary(); foreach (var keyValuePair in keyValuePairs) { - string[] keyValue = keyValuePair.Split(KeyValueSeperator); + // Split on the first '=' only so a value that itself contains '=' is preserved. + // Input: "data source=C:\a=b.sqlite" -> key="data source", value="C:\a=b.sqlite" + string[] keyValue = keyValuePair.Split(new[] { KeyValueSeperator }, 2, StringSplitOptions.None); if (keyValue.Length >= 2) { - keyValuePairDictionary.Add(keyValue[KeyPosition].Trim().ToLower(CultureInfo.InvariantCulture), keyValue[ValuePosition]); + // Indexer assignment (last value wins) so a repeated key does not throw. + keyValuePairDictionary[keyValue[KeyPosition].Trim().ToLower(CultureInfo.InvariantCulture)] = keyValue[ValuePosition]; } } From b1cafccc0670c1d5f054ce308f32678442d10129 Mon Sep 17 00:00:00 2001 From: Marc Sallin Date: Tue, 16 Jun 2026 02:52:46 +0200 Subject: [PATCH 50/56] refactor: minor correctness and clarity cleanups - AssociationTypeContainer: materialize the projection with ToList so GetAssociationTypes does not rebuild every SqliteAssociationType on each call. - ConnectionStringParser.GetDataSource: reuse the already-parsed dictionary instead of parsing the connection string a second time. - SqliteForeignKeyIndexConvention: fold the uniqueness suffix into the index name before escaping so it stays inside the quoted identifier instead of being appended after the closing quote. --- .../SqliteForeignKeyIndexConvention.cs | 18 +++++++++--------- .../Utility/AssociationTypeContainer.cs | 4 +++- .../Internal/Utility/ConnectionStringParser.cs | 2 +- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/SQLite.CodeFirst/Internal/Convention/SqliteForeignKeyIndexConvention.cs b/SQLite.CodeFirst/Internal/Convention/SqliteForeignKeyIndexConvention.cs index e10205e..e5d24ac 100644 --- a/SQLite.CodeFirst/Internal/Convention/SqliteForeignKeyIndexConvention.cs +++ b/SQLite.CodeFirst/Internal/Convention/SqliteForeignKeyIndexConvention.cs @@ -74,16 +74,16 @@ public virtual void Apply(AssociationType item, DbModel model) private static IndexAnnotation CreateIndexAnnotation(string tableName, string propertyName, int count) { - var indexName = IndexNameCreator.CreateName(tableName, propertyName); - - // If there are two Indicies on the same property, the count is added. - // In SQLite an Index name must be global unique. - // To be honest, it should never happen. But because its possible by using the API, it should be covered. - if (count > 0) - { - indexName = String.Format(CultureInfo.InvariantCulture, "{0}_{1}", indexName, count); - } + // If there are two indices on the same property, the count is appended. + // In SQLite an index name must be globally unique. + // To be honest, it should never happen. But because it is possible via the API, it is covered. + // The suffix is folded in before escaping so it stays inside the quoted identifier; + // IndexNameCreator.CreateName returns an already-escaped name. + string uniquePropertyName = count > 0 + ? String.Format(CultureInfo.InvariantCulture, "{0}_{1}", propertyName, count) + : propertyName; + var indexName = IndexNameCreator.CreateName(tableName, uniquePropertyName); var indexAttribute = new IndexAttribute(indexName); return new IndexAnnotation(indexAttribute); } diff --git a/SQLite.CodeFirst/Internal/Utility/AssociationTypeContainer.cs b/SQLite.CodeFirst/Internal/Utility/AssociationTypeContainer.cs index e86d20f..c22d1a9 100644 --- a/SQLite.CodeFirst/Internal/Utility/AssociationTypeContainer.cs +++ b/SQLite.CodeFirst/Internal/Utility/AssociationTypeContainer.cs @@ -10,7 +10,9 @@ internal class AssociationTypeContainer public AssociationTypeContainer(IEnumerable associationTypes, EntityContainer container) { - sqliteAssociationTypes = associationTypes.Select(associationType => new SqliteAssociationType(associationType, container)); + // Materialize once. GetAssociationTypes is called per entity set, so a deferred query + // would rebuild every SqliteAssociationType (and its entity-set lookups) on each call. + sqliteAssociationTypes = associationTypes.Select(associationType => new SqliteAssociationType(associationType, container)).ToList(); } public IEnumerable GetAssociationTypes(string entitySetName) diff --git a/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs b/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs index a146dfb..93592c6 100644 --- a/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs +++ b/SQLite.CodeFirst/Internal/Utility/ConnectionStringParser.cs @@ -21,7 +21,7 @@ public static string GetDataSource(string connectionString) IDictionary strings = ParseConnectionString(connectionString); if (strings.ContainsKey(DataSourceToken)) { - var path = ExpandDataDirectory(ParseConnectionString(connectionString)[DataSourceToken]); + var path = ExpandDataDirectory(strings[DataSourceToken]); return path.Trim('"'); } From 4b835d0e8fda057f140cdb1858afd7fe17e9e983 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 22 Jun 2026 10:09:56 +0000 Subject: [PATCH 51/56] Bump actions/checkout from 6 to 7 Bumps [actions/checkout](https://github.com/actions/checkout) from 6 to 7. - [Release notes](https://github.com/actions/checkout/releases) - [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md) - [Commits](https://github.com/actions/checkout/compare/v6...v7) --- updated-dependencies: - dependency-name: actions/checkout dependency-version: '7' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 1f3c728..59f6664 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -27,7 +27,7 @@ jobs: id-token: write # Required for NuGet Trusted Publishing; without it NuGet/login fails with 403. contents: write # Required to create the GitHub Release; a job-level block drops inherited defaults. steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Setup .NET uses: actions/setup-dotnet@v5 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 0ed5a17..9ecf110 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -14,7 +14,7 @@ jobs: runs-on: windows-latest timeout-minutes: 15 steps: - - uses: actions/checkout@v6 + - uses: actions/checkout@v7 - name: Setup .NET uses: actions/setup-dotnet@v5 From c46ca58f78d7e07d155e897f0aae669192a0a6ae Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2026 10:09:57 +0000 Subject: [PATCH 52/56] Bump actions/setup-dotnet from 5 to 6 Bumps [actions/setup-dotnet](https://github.com/actions/setup-dotnet) from 5 to 6. - [Release notes](https://github.com/actions/setup-dotnet/releases) - [Commits](https://github.com/actions/setup-dotnet/compare/v5...v6) --- updated-dependencies: - dependency-name: actions/setup-dotnet dependency-version: '6' dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] --- .github/workflows/cd.yml | 2 +- .github/workflows/ci.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cd.yml b/.github/workflows/cd.yml index 59f6664..0b060f7 100644 --- a/.github/workflows/cd.yml +++ b/.github/workflows/cd.yml @@ -30,7 +30,7 @@ jobs: - uses: actions/checkout@v7 - name: Setup .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@v6 with: # Install the exact SDK pinned in global.json; Dependabot's dotnet-sdk updater keeps it current. global-json-file: global.json diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 9ecf110..20ef1d0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -17,7 +17,7 @@ jobs: - uses: actions/checkout@v7 - name: Setup .NET - uses: actions/setup-dotnet@v5 + uses: actions/setup-dotnet@v6 with: # Install the exact SDK pinned in global.json; Dependabot's dotnet-sdk updater keeps it current. global-json-file: global.json From dcb16ef3310c99bbe51ca5c595b44aba98510069 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2026 10:09:52 +0000 Subject: [PATCH 53/56] Bump dotnet-sdk from 10.0.301 to 10.0.302 Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.301 to 10.0.302. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](https://github.com/dotnet/sdk/compare/v10.0.301...v10.0.302) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 10.0.302 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index f272fe7..b3e2010 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.301", + "version": "10.0.302", "rollForward": "latestMinor" }, "test": { From 3e03bb860f0e87fcfdb56ad87a71ae5eb16d48ea Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 20 Jul 2026 10:12:13 +0000 Subject: [PATCH 54/56] Bump the nuget-minor-and-patch group with 3 updates Bumps Microsoft.Testing.Extensions.TrxReport from 2.2.3 to 2.3.2 Bumps MSTest.TestAdapter from 4.2.3 to 4.3.2 Bumps MSTest.TestFramework from 4.2.3 to 4.3.2 --- updated-dependencies: - dependency-name: Microsoft.Testing.Extensions.TrxReport dependency-version: 2.3.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: nuget-minor-and-patch - dependency-name: MSTest.TestAdapter dependency-version: 4.3.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: nuget-minor-and-patch - dependency-name: MSTest.TestFramework dependency-version: 4.3.2 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: nuget-minor-and-patch ... Signed-off-by: dependabot[bot] --- .../SQLite.CodeFirst.Test.csproj | 6 +- SQLite.CodeFirst.Test/packages.lock.json | 72 +++++++++---------- 2 files changed, 39 insertions(+), 39 deletions(-) diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 0228e1e..622eaff 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -12,10 +12,10 @@ - - + + - + diff --git a/SQLite.CodeFirst.Test/packages.lock.json b/SQLite.CodeFirst.Test/packages.lock.json index 2dccd5e..17d2b97 100644 --- a/SQLite.CodeFirst.Test/packages.lock.json +++ b/SQLite.CodeFirst.Test/packages.lock.json @@ -4,12 +4,12 @@ "net10.0": { "Microsoft.Testing.Extensions.TrxReport": { "type": "Direct", - "requested": "[2.2.3, )", - "resolved": "2.2.3", - "contentHash": "9Hot3ty5ZVWHrW40k2NPfD0dCaPwIxj7j7VjujNYwpYkYw9AdbejPHjGNkL/gvUWorauJf5IkeDoUeIbS7LuUg==", + "requested": "[2.3.2, )", + "resolved": "2.3.2", + "contentHash": "JzCtiOAmIfkPP2PpAKZeiH1hVYIVC9jMhsPWrd6PnH/Wtuct1UMuxpKi2F1cmXgfokc/HOadC6HOO1qzI23tnA==", "dependencies": { - "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.2.3", - "Microsoft.Testing.Platform": "2.2.3" + "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.3.2", + "Microsoft.Testing.Platform": "2.3.2" } }, "Moq": { @@ -23,22 +23,22 @@ }, "MSTest.TestAdapter": { "type": "Direct", - "requested": "[4.2.3, )", - "resolved": "4.2.3", - "contentHash": "oVV/luk0bBghnVvLaw8MwFlD7It0Cx9P2nKobeqIafmTQqFFWY69Wo801dxjeNaLzO/o9WQ84WSK84gXJuubhg==", + "requested": "[4.3.2, )", + "resolved": "4.3.2", + "contentHash": "uqpjJqQ3ws5z7Pq6BfMFpuqdrN2YIfe0Gfww91LRVXwxBdLqUaJd4JbHUImOSQvmK5m3PqW285kPjKbb69QFoA==", "dependencies": { - "MSTest.TestFramework": "4.2.3", - "Microsoft.Testing.Extensions.VSTestBridge": "2.2.3", - "Microsoft.Testing.Platform.MSBuild": "2.2.3" + "MSTest.TestFramework": "4.3.2", + "Microsoft.Testing.Extensions.VSTestBridge": "2.3.2", + "Microsoft.Testing.Platform.MSBuild": "2.3.2" } }, "MSTest.TestFramework": { "type": "Direct", - "requested": "[4.2.3, )", - "resolved": "4.2.3", - "contentHash": "9zzij59YLh+tf+FRLNqhzHjmdspR91bol+jdQxLlxxTGMAML6LDbvuyXKMGdcrE84+QpKkk6KjTVBC5PBGrDeA==", + "requested": "[4.3.2, )", + "resolved": "4.3.2", + "contentHash": "Vlj3THt/BcOV/93k0Cdq29RNEsrY3TvUV6mF13rOuY8Gx7Ltd+LrOYId8AYu0cH9ioCYY/Sx1hppfI9p/vP+aw==", "dependencies": { - "MSTest.Analyzers": "4.2.3" + "MSTest.Analyzers": "4.3.2" } }, "Castle.Core": { @@ -67,49 +67,49 @@ }, "Microsoft.Testing.Extensions.Telemetry": { "type": "Transitive", - "resolved": "2.2.3", - "contentHash": "mLdW+JOR3kXYGTdgR/qc/UZBA0r+eCR2k6bUxTcuDj5w9WdIQ7Lol5MBUU7YOSGd9bs9bvhSYWAptgz0YtQqCA==", + "resolved": "2.3.2", + "contentHash": "Q1iapTk1DwFFT9aPtv4wxJHe22++NLxsg7IekEujac9RDAugxGQdCN0SQ1b9ryF78cdidhSBB17pHdCANurOyQ==", "dependencies": { "Microsoft.ApplicationInsights": "2.23.0", - "Microsoft.Testing.Platform": "2.2.3" + "Microsoft.Testing.Platform": "2.3.2" } }, "Microsoft.Testing.Extensions.TrxReport.Abstractions": { "type": "Transitive", - "resolved": "2.2.3", - "contentHash": "hntvxJEkmUAx6C2xXc/PO38DqEQl4rimzOgSvTR1hAMruMid7R4RcXOrzzF33J66gKaN7jRaQ0TMW/nNfaV9jw==", + "resolved": "2.3.2", + "contentHash": "frw+Qa6gUxOZSw2Mw6SPtJT9gPzcP4nS9TfQhS0cHXKL6Rcp/CqLG+o4Psc1bHAhxW04rpzTBhjpNMnw2L7BuQ==", "dependencies": { - "Microsoft.Testing.Platform": "2.2.3" + "Microsoft.Testing.Platform": "2.3.2" } }, "Microsoft.Testing.Extensions.VSTestBridge": { "type": "Transitive", - "resolved": "2.2.3", - "contentHash": "7WlJISO8QKUK+d+WhgnANwy4ACwUrvICnviY/mthPwjZ2gVeDaSUAeBnMy2cxfzZgm8VATtGUDbYzUxsgV2CyQ==", + "resolved": "2.3.2", + "contentHash": "DXJIaLlwt+6GnPurlf7eVMI0wAZV5KCZrgGPibhx9i9LNxAkwEOK2jVzdVjLvvZ/SX9MUUaGJB9yXuF/VoT4/w==", "dependencies": { - "Microsoft.TestPlatform.ObjectModel": "18.3.0", - "Microsoft.Testing.Extensions.Telemetry": "2.2.3", - "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.2.3", - "Microsoft.Testing.Platform": "2.2.3" + "Microsoft.TestPlatform.ObjectModel": "18.4.0", + "Microsoft.Testing.Extensions.Telemetry": "2.3.2", + "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.3.2", + "Microsoft.Testing.Platform": "2.3.2" } }, "Microsoft.Testing.Platform": { "type": "Transitive", - "resolved": "2.2.3", - "contentHash": "LhM1/Qoi8Ams5QcD4r3f09CSOono9iQr3NEJQItFtyzWB55nWTgEOsVqXqMWWWIwk3nkPqc+XfnlJmp8xUI5fg==" + "resolved": "2.3.2", + "contentHash": "FuJgIEfNU+rFHJYGhuqA8uup+3cryJ1N67Tijqo01Jd5xAr28ptz0aXkFfSqK3MhAUmGsrPpgQ92+3+0oXv8AA==" }, "Microsoft.Testing.Platform.MSBuild": { "type": "Transitive", - "resolved": "2.2.3", - "contentHash": "Q22jJYJLx4srTinsAuoCskqmzjrBJC8YeGJMHHIcrf1dQeHoEZ7wsqDzTlENkMoke2qfufF7U+9u58nlZunH/Q==", + "resolved": "2.3.2", + "contentHash": "guFvvaE8FGUlB6h24jN+P+NBz/P5x4On9sk4n5UapUAPq4fr0y1AgUe4sXmItp7r2NMe3rhZYLE1teP9T9sVbg==", "dependencies": { - "Microsoft.Testing.Platform": "2.2.3" + "Microsoft.Testing.Platform": "2.3.2" } }, "Microsoft.TestPlatform.ObjectModel": { "type": "Transitive", - "resolved": "18.3.0", - "contentHash": "AEIEX2aWdPO9XbtR96eBaJxmXRD9vaI9uQ1T/JbPEKlTAZwYx0ZrMzKyULMdh/HH9Sg03kXCoN7LszQ90o6nPQ==" + "resolved": "18.4.0", + "contentHash": "4L6m2kS2pY5uJ9cpeRxzW22opr6ttScIRqsOpMDQpgENp/ZwxkkQCcmc6LRSURo2dFaaSW5KVflQZvroiJ7Wzg==" }, "Microsoft.Win32.SystemEvents": { "type": "Transitive", @@ -118,8 +118,8 @@ }, "MSTest.Analyzers": { "type": "Transitive", - "resolved": "4.2.3", - "contentHash": "dxOZt8/LWuiox7rugInJoIa5Mmu3pBmXdfaoZOx/mxx8+sUFFpjBXPlWXQXGeWzpkVPNC3x1Jf7rt2h2Zjyvvg==" + "resolved": "4.3.2", + "contentHash": "GNvrVI6/Y5pNoKnK1/VELBls3XiHNZaj+zh14LtwlCqFI8zXTW3vuBe0Jv2qEr9wxHlOAQQBTJPRoNRjneGrKQ==" }, "runtime.native.System.Data.SqlClient.sni": { "type": "Transitive", From c9e4aef2351f7b8ef1ef5baf4862c2731efbbee8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Sep 2026 10:09:52 +0000 Subject: [PATCH 55/56] Bump the nuget-minor-and-patch group with 3 updates Bumps Microsoft.Testing.Extensions.TrxReport from 2.3.2 to 2.4.0 Bumps MSTest.TestAdapter from 4.3.2 to 4.4.0 Bumps MSTest.TestFramework from 4.3.2 to 4.4.0 --- updated-dependencies: - dependency-name: Microsoft.Testing.Extensions.TrxReport dependency-version: 2.4.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: nuget-minor-and-patch - dependency-name: MSTest.TestAdapter dependency-version: 4.4.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: nuget-minor-and-patch - dependency-name: MSTest.TestFramework dependency-version: 4.4.0 dependency-type: direct:production update-type: version-update:semver-minor dependency-group: nuget-minor-and-patch ... Signed-off-by: dependabot[bot] --- .../SQLite.CodeFirst.Test.csproj | 6 +- SQLite.CodeFirst.Test/packages.lock.json | 73 ++++++++----------- 2 files changed, 35 insertions(+), 44 deletions(-) diff --git a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj index 622eaff..bda6a61 100644 --- a/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj +++ b/SQLite.CodeFirst.Test/SQLite.CodeFirst.Test.csproj @@ -12,10 +12,10 @@ - - + + - + diff --git a/SQLite.CodeFirst.Test/packages.lock.json b/SQLite.CodeFirst.Test/packages.lock.json index 17d2b97..1ba4cbd 100644 --- a/SQLite.CodeFirst.Test/packages.lock.json +++ b/SQLite.CodeFirst.Test/packages.lock.json @@ -4,12 +4,12 @@ "net10.0": { "Microsoft.Testing.Extensions.TrxReport": { "type": "Direct", - "requested": "[2.3.2, )", - "resolved": "2.3.2", - "contentHash": "JzCtiOAmIfkPP2PpAKZeiH1hVYIVC9jMhsPWrd6PnH/Wtuct1UMuxpKi2F1cmXgfokc/HOadC6HOO1qzI23tnA==", + "requested": "[2.4.0, )", + "resolved": "2.4.0", + "contentHash": "WkOaIp/ivwcaF34rmUAIjafnWJ/chI/2hvH/wLQlLXKNDDvaRYvjkxWC7l0+Ib+C4dGrylUonM4kHwJujlkVKw==", "dependencies": { - "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.3.2", - "Microsoft.Testing.Platform": "2.3.2" + "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.4.0", + "Microsoft.Testing.Platform": "[2.4.0, 3.0.0)" } }, "Moq": { @@ -23,22 +23,24 @@ }, "MSTest.TestAdapter": { "type": "Direct", - "requested": "[4.3.2, )", - "resolved": "4.3.2", - "contentHash": "uqpjJqQ3ws5z7Pq6BfMFpuqdrN2YIfe0Gfww91LRVXwxBdLqUaJd4JbHUImOSQvmK5m3PqW285kPjKbb69QFoA==", + "requested": "[4.4.0, )", + "resolved": "4.4.0", + "contentHash": "xZdlCr2r/6XFOo67jcemJsfm46tTgXdqtnISFIuDUAJf5Yxk07XpTC9eMUErLdlYD8QM9zw07eOPre7+nTayUg==", "dependencies": { - "MSTest.TestFramework": "4.3.2", - "Microsoft.Testing.Extensions.VSTestBridge": "2.3.2", - "Microsoft.Testing.Platform.MSBuild": "2.3.2" + "MSTest.TestFramework": "4.4.0", + "Microsoft.TestPlatform.ObjectModel": "18.9.0", + "Microsoft.Testing.Extensions.Telemetry": "2.4.0", + "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.4.0", + "Microsoft.Testing.Platform.MSBuild": "2.4.0" } }, "MSTest.TestFramework": { "type": "Direct", - "requested": "[4.3.2, )", - "resolved": "4.3.2", - "contentHash": "Vlj3THt/BcOV/93k0Cdq29RNEsrY3TvUV6mF13rOuY8Gx7Ltd+LrOYId8AYu0cH9ioCYY/Sx1hppfI9p/vP+aw==", + "requested": "[4.4.0, )", + "resolved": "4.4.0", + "contentHash": "sfJzj3ntdU/GahJd2n+WQLgKqbV0RRMJVXtjRwRQLhblevlzLSDAOocOKANhfMaCEQ5dMt6348ztbVq/Ap60xA==", "dependencies": { - "MSTest.Analyzers": "4.3.2" + "MSTest.Analyzers": "4.4.0" } }, "Castle.Core": { @@ -67,49 +69,38 @@ }, "Microsoft.Testing.Extensions.Telemetry": { "type": "Transitive", - "resolved": "2.3.2", - "contentHash": "Q1iapTk1DwFFT9aPtv4wxJHe22++NLxsg7IekEujac9RDAugxGQdCN0SQ1b9ryF78cdidhSBB17pHdCANurOyQ==", + "resolved": "2.4.0", + "contentHash": "JeP1RFqBa11fWmBk8xEfZcMKr4rxWSyI6OZ+659V069CaMkTEOQBW2UdSSeNz3absOsygcn7JJkzerC4LGnZ9w==", "dependencies": { "Microsoft.ApplicationInsights": "2.23.0", - "Microsoft.Testing.Platform": "2.3.2" + "Microsoft.Testing.Platform": "[2.4.0, 3.0.0)" } }, "Microsoft.Testing.Extensions.TrxReport.Abstractions": { "type": "Transitive", - "resolved": "2.3.2", - "contentHash": "frw+Qa6gUxOZSw2Mw6SPtJT9gPzcP4nS9TfQhS0cHXKL6Rcp/CqLG+o4Psc1bHAhxW04rpzTBhjpNMnw2L7BuQ==", + "resolved": "2.4.0", + "contentHash": "uRb+4qM42dFDg4kWJZ2kFEcwESNVCRZJjItp5vETorN3rSJGysP617LqYirOcrCYmxg+obPreHMM5JcsNDKtBw==", "dependencies": { - "Microsoft.Testing.Platform": "2.3.2" - } - }, - "Microsoft.Testing.Extensions.VSTestBridge": { - "type": "Transitive", - "resolved": "2.3.2", - "contentHash": "DXJIaLlwt+6GnPurlf7eVMI0wAZV5KCZrgGPibhx9i9LNxAkwEOK2jVzdVjLvvZ/SX9MUUaGJB9yXuF/VoT4/w==", - "dependencies": { - "Microsoft.TestPlatform.ObjectModel": "18.4.0", - "Microsoft.Testing.Extensions.Telemetry": "2.3.2", - "Microsoft.Testing.Extensions.TrxReport.Abstractions": "2.3.2", - "Microsoft.Testing.Platform": "2.3.2" + "Microsoft.Testing.Platform": "[2.4.0, 3.0.0)" } }, "Microsoft.Testing.Platform": { "type": "Transitive", - "resolved": "2.3.2", - "contentHash": "FuJgIEfNU+rFHJYGhuqA8uup+3cryJ1N67Tijqo01Jd5xAr28ptz0aXkFfSqK3MhAUmGsrPpgQ92+3+0oXv8AA==" + "resolved": "2.4.0", + "contentHash": "dp1N3P1ujb0ztwFgqz2o/ItEvq+pm19/AiA+Xq7Zpcy7oPMcxDBZLYGtf0LlU1MveEBJuKVjZhI+LnkfcH/0jQ==" }, "Microsoft.Testing.Platform.MSBuild": { "type": "Transitive", - "resolved": "2.3.2", - "contentHash": "guFvvaE8FGUlB6h24jN+P+NBz/P5x4On9sk4n5UapUAPq4fr0y1AgUe4sXmItp7r2NMe3rhZYLE1teP9T9sVbg==", + "resolved": "2.4.0", + "contentHash": "qr5M6h16YHMJLFDcWELFVMMpGte2BUmveBZKT5YoBV+bmuJRPu9bv/Zqke4yQuOEKRNxoAETrG5jr+/6Rnr3Hg==", "dependencies": { - "Microsoft.Testing.Platform": "2.3.2" + "Microsoft.Testing.Platform": "[2.4.0, 3.0.0)" } }, "Microsoft.TestPlatform.ObjectModel": { "type": "Transitive", - "resolved": "18.4.0", - "contentHash": "4L6m2kS2pY5uJ9cpeRxzW22opr6ttScIRqsOpMDQpgENp/ZwxkkQCcmc6LRSURo2dFaaSW5KVflQZvroiJ7Wzg==" + "resolved": "18.9.0", + "contentHash": "Fz/qXC52VXXopzHj7v2reCKcCqSxkTDCkEDfkNAH0vni/7qK/KLMiEYtRmnUanxO2F2g2zZZ60qCpxF0AF7URA==" }, "Microsoft.Win32.SystemEvents": { "type": "Transitive", @@ -118,8 +109,8 @@ }, "MSTest.Analyzers": { "type": "Transitive", - "resolved": "4.3.2", - "contentHash": "GNvrVI6/Y5pNoKnK1/VELBls3XiHNZaj+zh14LtwlCqFI8zXTW3vuBe0Jv2qEr9wxHlOAQQBTJPRoNRjneGrKQ==" + "resolved": "4.4.0", + "contentHash": "8g2KL2LjsXXVywvQb0uWQBANOONVnRf6cTSbON9ar6gIw08oSBY7Z3PJlC8sHbqOVvCr7srrcWiKzb12SUoV2w==" }, "runtime.native.System.Data.SqlClient.sni": { "type": "Transitive", From 6f6629a2ff83dd76322c4272b6566d5214dc8e1a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 14 Sep 2026 10:07:56 +0000 Subject: [PATCH 56/56] Bump dotnet-sdk from 10.0.302 to 10.0.401 Bumps [dotnet-sdk](https://github.com/dotnet/sdk) from 10.0.302 to 10.0.401. - [Release notes](https://github.com/dotnet/sdk/releases) - [Commits](https://github.com/dotnet/sdk/compare/v10.0.302...v10.0.401) --- updated-dependencies: - dependency-name: dotnet-sdk dependency-version: 10.0.401 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- global.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/global.json b/global.json index b3e2010..d323864 100644 --- a/global.json +++ b/global.json @@ -1,6 +1,6 @@ { "sdk": { - "version": "10.0.302", + "version": "10.0.401", "rollForward": "latestMinor" }, "test": {