diff --git a/.gitignore b/.gitignore
index f863a14..c77e706 100644
--- a/.gitignore
+++ b/.gitignore
@@ -163,3 +163,8 @@ SampleWebApp/Properties/PublishProfiles/samplemvcwebapp - Web Deploy.pubxml
SampleWebApp/Properties/PublishProfiles/samplemvcwebapp.net - WebWiz.pubxml
git/.gitattributes
git/.gitignore
+
+# SQLite dev database
+*.db
+*.db-shm
+*.db-wal
diff --git a/BizLayer/App.config b/BizLayer/App.config
deleted file mode 100644
index 13ecece..0000000
--- a/BizLayer/App.config
+++ /dev/null
@@ -1,17 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/BizLayer/BizLayer.csproj b/BizLayer/BizLayer.csproj
index aa58ad0..3ce449a 100644
--- a/BizLayer/BizLayer.csproj
+++ b/BizLayer/BizLayer.csproj
@@ -1,87 +1,14 @@
-
-
-
+
+
- Debug
- AnyCPU
- {19592A8F-7C58-4221-8124-D38ACD8F5E31}
- Library
- Properties
+ net9.0
+ disable
+ disable
BizLayer
- BizLayer
- v4.5.1
- 512
-
- true
- full
- false
- bin\Debug\
- DEBUG;TRACE
- prompt
- 4
-
-
- pdbonly
- true
- bin\Release\
- TRACE
- prompt
- 4
-
-
-
- ..\packages\Autofac.3.5.0\lib\net40\Autofac.dll
-
-
- ..\packages\AutoMapper.3.2.1\lib\net40\AutoMapper.dll
-
-
- ..\packages\AutoMapper.3.2.1\lib\net40\AutoMapper.Net4.dll
-
-
- False
- ..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.dll
-
-
- ..\packages\EntityFramework.6.1.1\lib\net45\EntityFramework.SqlServer.dll
-
-
- False
- ..\packages\GenericServices.1.0.0-beta4-003\lib\GenericServices.dll
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
- {264e1878-12de-4099-b8d7-cc53a73fea49}
- DataLayer
-
+
-
-
-
-
-
\ No newline at end of file
+
+
diff --git a/BizLayer/Properties/AssemblyInfo.cs b/BizLayer/Properties/AssemblyInfo.cs
deleted file mode 100644
index f93aad5..0000000
--- a/BizLayer/Properties/AssemblyInfo.cs
+++ /dev/null
@@ -1,62 +0,0 @@
-#region licence
-// The MIT License (MIT)
-//
-// Filename: AssemblyInfo.cs
-// Date Created: 2014/07/11
-//
-// Copyright (c) 2014 Jon Smith (www.selectiveanalytics.com & www.thereformedprogrammer.net)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-#endregion
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// General Information about an assembly is controlled through the following
-// set of attributes. Change these attribute values to modify the information
-// associated with an assembly.
-[assembly: AssemblyTitle("BizLayer")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("BizLayer")]
-[assembly: AssemblyCopyright("Copyright © 2014")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// Setting ComVisible to false makes the types in this assembly not visible
-// to COM components. If you need to access a type in this assembly from
-// COM, set the ComVisible attribute to true on that type.
-[assembly: ComVisible(false)]
-
-// The following GUID is for the ID of the typelib if this project is exposed to COM
-[assembly: Guid("3ea2faa1-4bb3-4d8e-8d35-f8038d375643")]
-
-// Version information for an assembly consists of the following four values:
-//
-// Major Version
-// Minor Version
-// Build Number
-// Revision
-//
-// You can specify all the values or you can default the Build and Revision Numbers
-// by using the '*' as shown below:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/BizLayer/Startup/BizLayerModule.cs b/BizLayer/Startup/BizLayerModule.cs
deleted file mode 100644
index e924a90..0000000
--- a/BizLayer/Startup/BizLayerModule.cs
+++ /dev/null
@@ -1,46 +0,0 @@
-#region licence
-// The MIT License (MIT)
-//
-// Filename: BizLayerModule.cs
-// Date Created: 2014/07/11
-//
-// Copyright (c) 2014 Jon Smith (www.selectiveanalytics.com & www.thereformedprogrammer.net)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-#endregion
-using Autofac;
-
-namespace BizLayer.Startup
-{
- public class BizLayerModule : Module
- {
-
- ///
- /// This registers all items in service layer and below
- ///
- ///
- protected override void Load(ContainerBuilder builder)
- {
- //---------------------------
- //Register service layer: autowire all
- builder.RegisterAssemblyTypes(GetType().Assembly).AsImplementedInterfaces();
- }
-
- }
-}
diff --git a/BizLayer/packages.config b/BizLayer/packages.config
deleted file mode 100644
index 4a74205..0000000
--- a/BizLayer/packages.config
+++ /dev/null
@@ -1,7 +0,0 @@
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DataLayer/App.config b/DataLayer/App.config
deleted file mode 100644
index 5b4002b..0000000
--- a/DataLayer/App.config
+++ /dev/null
@@ -1,25 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/DataLayer/DataClasses/EfConfiguration.cs b/DataLayer/DataClasses/EfConfiguration.cs
deleted file mode 100644
index 8c3cfe7..0000000
--- a/DataLayer/DataClasses/EfConfiguration.cs
+++ /dev/null
@@ -1,48 +0,0 @@
-#region licence
-// The MIT License (MIT)
-//
-// Filename: EfConfiguration.cs
-// Date Created: 2014/08/14
-//
-// Copyright (c) 2014 Jon Smith (www.selectiveanalytics.com & www.thereformedprogrammer.net)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-#endregion
-
-using System.Data.Entity;
-using System.Data.Entity.SqlServer;
-
-namespace DataLayer.DataClasses
-{
- public class EfConfiguration : DbConfiguration
- {
- ///
- /// This flag should be set to true if we are working with an Azure database.
- /// It should be set before EF uses the configuration, i.e. beofre the first access
- ///
- public static bool IsAzure { get; internal set; }
-
- public EfConfiguration()
- {
- if (IsAzure)
- SetExecutionStrategy("System.Data.SqlClient", () => new SqlAzureExecutionStrategy());
- }
-
- }
-}
diff --git a/DataLayer/DataClasses/SampleWebAppDb.cs b/DataLayer/DataClasses/SampleWebAppDb.cs
index 0a86cf3..0b59449 100644
--- a/DataLayer/DataClasses/SampleWebAppDb.cs
+++ b/DataLayer/DataClasses/SampleWebAppDb.cs
@@ -1,134 +1,84 @@
-#region licence
-// The MIT License (MIT)
-//
-// Filename: SampleWebAppDb.cs
-// Date Created: 2014/05/20
-//
-// Copyright (c) 2014 Jon Smith (www.selectiveanalytics.com & www.thereformedprogrammer.net)
-//
-// Permission is hereby granted, free of charge, to any person obtaining a copy
-// of this software and associated documentation files (the "Software"), to deal
-// in the Software without restriction, including without limitation the rights
-// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-// copies of the Software, and to permit persons to whom the Software is
-// furnished to do so, subject to the following conditions:
-//
-// The above copyright notice and this permission notice shall be included in all
-// copies or substantial portions of the Software.
-//
-// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-// SOFTWARE.
-#endregion
using System.Collections.Generic;
-using System.Data.Entity;
-using System.Data.Entity.Infrastructure;
-using System.Data.Entity.Validation;
+using System.ComponentModel.DataAnnotations;
using System.Linq;
using System.Runtime.CompilerServices;
-using System.Threading.Tasks;
using DataLayer.DataClasses.Concrete;
using DataLayer.DataClasses.Concrete.Helpers;
using GenericServices;
+using Microsoft.EntityFrameworkCore;
+using Microsoft.EntityFrameworkCore.ChangeTracking;
[assembly: InternalsVisibleTo("Tests")]
namespace DataLayer.DataClasses
{
-
public class SampleWebAppDb : DbContext, IGenericServicesDbContext
{
- internal const string NameOfConnectionString = "SampleWebAppDb";
-
public DbSet Blogs { get; set; }
public DbSet Posts { get; set; }
public DbSet Tags { get; set; }
- public SampleWebAppDb() : base("name=" + NameOfConnectionString) {}
+ public SampleWebAppDb(DbContextOptions options) : base(options) { }
+
+ protected override void OnModelCreating(ModelBuilder modelBuilder)
+ {
+ base.OnModelCreating(modelBuilder);
- internal SampleWebAppDb(string connectionString) : base(connectionString) { }
+ modelBuilder.Entity()
+ .HasOne(p => p.Blogger)
+ .WithMany(b => b.Posts)
+ .HasForeignKey(p => p.BlogId);
+ modelBuilder.Entity()
+ .HasMany(p => p.Tags)
+ .WithMany(t => t.Posts);
+ }
///
- /// This has been overridden to handle:
- /// a) Updating of modified items (see p194 in DbContext book)
+ /// Overridden to update the LastUpdated tracking information before saving (see TrackUpdate).
///
- ///
public override int SaveChanges()
{
HandleChangeTracking();
return base.SaveChanges();
}
- ///
- /// Same for async
- ///
- ///
- public override Task SaveChangesAsync()
+ public override System.Threading.Tasks.Task SaveChangesAsync(
+ System.Threading.CancellationToken cancellationToken = default)
{
HandleChangeTracking();
- return base.SaveChangesAsync();
+ return base.SaveChangesAsync(cancellationToken);
}
///
- /// This does validations that can only be done at the database level
+ /// Database level validation that cannot be expressed via DataAnnotations.
+ /// Enforces uniqueness of a Tag's Slug.
///
- ///
- ///
- ///
- protected override DbEntityValidationResult ValidateEntity(DbEntityEntry entityEntry,
- IDictionary