VoidCore.Model 17.0.2

dotnet add package VoidCore.Model --version 17.0.2
                    
NuGet\Install-Package VoidCore.Model -Version 17.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="VoidCore.Model" Version="17.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="VoidCore.Model" Version="17.0.2" />
                    
Directory.Packages.props
<PackageReference Include="VoidCore.Model" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add VoidCore.Model --version 17.0.2
                    
#r "nuget: VoidCore.Model, 17.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package VoidCore.Model@17.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=VoidCore.Model&version=17.0.2
                    
Install as a Cake Addin
#tool nuget:?package=VoidCore.Model&version=17.0.2
                    
Install as a Cake Tool

VoidCore

License Build Status

VoidCore is a set of core libraries for building business applications on .NET.

FoodStuffs is a comprehensive example of how applications can be built using VoidCore.

Documentation

VoidCore is split into packages so you only get what you need.

Docs Description Release
VoidCore.Model An opinionated core for building business applications. NuGet package
VoidCore.AspNet Configure ASP.NET web applications based on VoidCore.Model. Includes single-page front end support. NuGet package
VoidCore.EntityFramework Entity Framework Core data access for applications based on VoidCore.Model. NuGet package
VoidCore.Finance A financial library with primary focus on simple amortization and time-value of money. NuGet package

Upgrading

Upgrading to 17.0

Audit and soft-delete timestamps are now always UTC DateTimeOffset values, and time is supplied by .NET's built-in TimeProvider. There is one convention and one set of types.

Removed
  • IDateTimeService, NowDateTimeService, UtcNowDateTimeService, DiscreteDateTimeService. Use TimeProvider instead.
  • IAuditableWithOffset and ISoftDeletableWithOffset. IAuditable and ISoftDeletable now use DateTimeOffset.
  • AddAuditabilityWithOffset and AddSoftDeletabilityWithOffset. Use AddAuditability and AddSoftDeletability.
  • The DateTime overloads of SetAuditCreated, SetAuditModified, and SetSoftDeleted.
Changed
  • AddAuditability, AddSoftDeletability, and SetAuditableProperties take a TimeProvider instead of an IDateTimeService.
  • IAuditable.CreatedOn/ModifiedOn and ISoftDeletable.DeletedOn are DateTimeOffset (DeletedOn is nullable).
  • SetAuditableProperties previously passed a DateTime to entities implementing IAuditableWithOffset. It now sets the correct UTC value.
  • ICurrentUserAccessor has a new synchronous string GetUserName(). Custom implementations must add it. It should return the same name as GetUser().Login without evaluating policies.
Added
  • AuditableSaveChangesInterceptor and SoftDeletableSaveChangesInterceptor in VoidCore.EntityFramework set audit and soft-delete properties for both SaveChanges and SaveChangesAsync. They replace overriding SaveChanges in your DbContext. See Entity Framework.
  • ApplySoftDeleteQueryFilter() hides soft-deleted entities from queries. IncludeSoftDeleted() and OnlySoftDeleted() bypass that filter, for example for a recycle bin.
  • SoftDeletableSaveChangesInterceptor.RequireRecycleBin makes soft-deleting before permanently deleting mandatory.
  • MapHealthEndpoint() in VoidCore.AspNet maps a /health endpoint that returns 200 or 503 with each check's description and exception message in a JSON body. See ASP.NET.
Steps
  1. Register a TimeProvider in dependency injection.

    services.AddSingleton(TimeProvider.System);
    
  2. Replace IDateTimeService constructor parameters and fields with TimeProvider. Moment and MomentWithOffset become GetUtcNow() (which returns a UTC DateTimeOffset).

  3. In tests, replace DiscreteDateTimeService with FakeTimeProvider from the Microsoft.Extensions.TimeProvider.Testing package.

    var timeProvider = new FakeTimeProvider(new DateTimeOffset(2001, 2, 12, 0, 0, 0, TimeSpan.Zero));
    
  4. Change entity properties from DateTime to DateTimeOffset (and DateTime? to DateTimeOffset?). Replace IAuditableWithOffset/ISoftDeletableWithOffset with IAuditable/ISoftDeletable.

  5. Replace calls to AddAuditabilityWithOffset and AddSoftDeletabilityWithOffset with AddAuditability and AddSoftDeletability.

  6. Add an EF migration to convert existing datetime/datetime2 columns to datetimeoffset. Remove any HasColumnType("datetime") mappings on those properties. Existing values that were stored as local time must be converted to UTC during the migration or they will be misread. Values already stored as UTC can be converted directly.

    -- Only if values were stored as local time (adjust the time zone name): convert them to UTC first.
    UPDATE dbo.Recipe SET CreatedOn = CreatedOn AT TIME ZONE 'Central Standard Time' AT TIME ZONE 'UTC';
    
    -- Then convert the column. Existing values are treated as UTC (+00:00).
    ALTER TABLE dbo.Recipe ALTER COLUMN CreatedOn datetimeoffset NOT NULL;
    

    Repeat for each audit and soft-delete column.

  7. Add GetUserName() to any custom ICurrentUserAccessor implementation.

  8. If your DbContext overrides SaveChanges and SaveChangesAsync to call SetAuditableProperties, remove the overrides and the TimeProvider and ICurrentUserAccessor constructor parameters. Register the interceptors instead. The interceptors are singletons, so ICurrentUserAccessor and TimeProvider must be singletons too.

    services.AddSingleton<AuditableSaveChangesInterceptor>();
    services.AddSingleton<SoftDeletableSaveChangesInterceptor>(); // Only if you use ISoftDeletable.
    
    services.AddDbContext<MyDbContext>((provider, options) => options
        .UseSqlServer(connectionString)
        .AddInterceptors(
            provider.GetRequiredService<AuditableSaveChangesInterceptor>(),
            provider.GetRequiredService<SoftDeletableSaveChangesInterceptor>()));
    

    The AddAuditability and AddSoftDeletability repository decorators still work for non-EF repositories but shouldn't be combined with the interceptors.

Developers

VoidCore is built on GitHub Actions and released on Nuget. To release, run the CI workflow manually on main. It builds, pushes to NuGet using trusted publishing, then tags and creates the GitHub release.

To work on VoidCore, you will need the .NET SDK and PowerShell.

See the /build folder for scripts used to test and build this project. Run build.ps1 to make a production build.

./build/build.ps1

There are VSCode tasks for each script. The build task (ctrl + shift + b) performs the standard CI build.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on VoidCore.Model:

Package Downloads
VoidCore.AspNet

Configure an ASP.NET web applications based on VoidCore.Model. Includes single-page front end support.

VoidCore.EntityFramework

Entity Framework Core data access for applications based on VoidCore.Model.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
17.0.2 122 10/26/2026
16.0.7 123 10/18/2026
15.3.1 544 8/3/2025
15.1.4 569 4/4/2025
15.0.1 432 3/12/2025
14.1.3 504 11/18/2024
14.1.1 440 10/19/2024
14.0.5 444 5/27/2024
13.0.3 459 3/22/2024
12.1.5 473 2/10/2024
12.1.2 612 12/1/2023
12.1.1 487 12/1/2023
12.0.7 481 11/17/2023
12.0.6 494 11/17/2023
12.0.3 496 11/15/2023
11.1.1 507 11/1/2023
11.0.6 633 9/17/2023
11.0.5 654 9/16/2023
11.0.2 697 8/23/2023
10.0.4 674 8/18/2023
Loading failed