Pondhawk.Rules.EFCore 1.0.24

dotnet add package Pondhawk.Rules.EFCore --version 1.0.24
                    
NuGet\Install-Package Pondhawk.Rules.EFCore -Version 1.0.24
                    
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="Pondhawk.Rules.EFCore" Version="1.0.24" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Pondhawk.Rules.EFCore" Version="1.0.24" />
                    
Directory.Packages.props
<PackageReference Include="Pondhawk.Rules.EFCore" />
                    
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 Pondhawk.Rules.EFCore --version 1.0.24
                    
#r "nuget: Pondhawk.Rules.EFCore, 1.0.24"
                    
#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 Pondhawk.Rules.EFCore@1.0.24
                    
#: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=Pondhawk.Rules.EFCore&version=1.0.24
                    
Install as a Cake Addin
#tool nuget:?package=Pondhawk.Rules.EFCore&version=1.0.24
                    
Install as a Cake Tool

Pondhawk.Rules.EFCore

Pre-save entity validation interceptor for EF Core powered by the Pondhawk.Rules engine. Validates all Added and Modified entities through your rule set before they reach the database.

Quick Start

Configure Validation

using Pondhawk.Rules.EFCore;
using Pondhawk.Rules.Factory;

// Define validation rules
var ruleSet = new RuleSet();

ruleSet.AddValidation<Order>("total-positive")
    .Assert<decimal>(o => o.Total)
    .IsGreaterThan(0m);

ruleSet.AddValidation<Order>("items-required")
    .AssertOver<OrderItem>(o => o.Items)
    .IsNotEmpty();

// Wire into DbContext
var options = new DbContextOptionsBuilder<AppContext>()
    .UseSqlServer(connectionString)
    .AddRuleValidation(ruleSet)
    .Options;

Automatic SaveChanges Validation

var context = new AppContext(options);

var order = new Order { Total = 100m, Items = [new OrderItem()] };
context.Orders.Add(order);

await context.SaveChangesAsync();
// Interceptor validates all Added/Modified entities
// Throws EntityValidationException if violations exist

Handle Validation Failures

try
{
    await context.SaveChangesAsync();
}
catch (EntityValidationException ex)
{
    var violations = ex.ValidationResult.Violations;
    // violations contains the structured RuleEvent violations
}

How It Works

  • RuleValidationInterceptor extends SaveChangesInterceptor.
  • On SavingChanges/SavingChangesAsync, it pulls all Added and Modified entities from ChangeTracker.
  • Each entity is validated through IRuleSet.Validate().
  • If any entity fails validation, EntityValidationException is thrown before the save reaches the database.
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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.24 113 3/4/2026
1.0.23 101 3/4/2026
1.0.21 107 2/16/2026
1.0.18 111 2/16/2026
1.0.8 102 2/15/2026
1.0.4 103 2/15/2026
1.0.3 106 2/14/2026