slothful-crud 1.1.0

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

<div align="center"> <img src="docs/assets/slothful-api.jpg" alt="slothful-api logo"> </div>

Slothful CRUD

Slothful CRUD helps you generate CRUD API endpoints for your entities with minimal setup.
Implement ISlothfulEntity, register the library, and expose REST endpoints backed by your DbContext.

Documentation

Full documentation is available at slothful.dev.

Quick Start

  1. Install package:
dotnet add package slothful-crud
  1. Register services and endpoint generation:
using SlothfulCrud.Extensions;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDbContext<SlothfulDbContext>(options =>
    options.UseInMemoryDatabase("AppDb"));
builder.Services.AddSlothfulCrud<SlothfulDbContext, Program>();

var app = builder.Build();
app.UseSlothfulCrud<SlothfulDbContext, Program>();

app.Run();

The Program type parameter serves as an assembly marker for entity discovery. You can use any type from the assembly containing your entities.

  1. Implement ISlothfulEntity on your domain type:
using SlothfulCrud.Domain;

public class Sloth : ISlothfulEntity
{
    public Guid Id { get; private set; }
    public string Name { get; private set; }
    public int Age { get; private set; }
    public string DisplayName => Name;

    public Sloth(Guid id, string name, int age)
    {
        Id = id;
        Name = name;
        Age = age;
    }

    public void Update(string name, int age)
    {
        Name = name;
        Age = age;
    }
}

Generated Endpoints

By default, the following endpoints are generated per entity:

  • GET /{segment}/{id} - details
  • GET /{segment}/list/{page} - browse
  • GET /{segment}/selectable-list/{page} - browse selectable
  • POST /{segment} - create
  • PUT /{segment}/{id} - update
  • DELETE /{segment}/{id} - delete

Important Notes

  • POST create request body does not include id; the key is generated server-side.
  • 201 Created includes Location: /{segment}/{id} and uses IApiSegmentProvider.
  • Validation is enabled by default (HasValidation = true). Register validators, e.g.:
builder.Services.AddValidatorsFromAssemblyContaining<YourValidator>();

Common Customizations

  • Endpoint segment strategy (IApiSegmentProvider)
  • Key generation strategy (IEntityPropertyKeyValueProvider<TEntity>)
  • Create constructor selection (ICreateConstructorBehavior)
  • Entity and endpoint configuration (ISlothEntityConfiguration<T>)
  • Problem handling (UseSlothfulProblemHandling)
  • Query customization (QueryCustomizer in SlothfulOptions)

Performance Benchmarking

BenchmarkDotNet benchmarks are included to track performance regressions and compare internal changes.

Run all benchmarks:

dotnet run -c Release --project library/SlothfulCrud/Tests/SlothfulCrud.Benchmarks -- --filter "*"

Results are exported to:

library/SlothfulCrud/Tests/SlothfulCrud.Benchmarks/BenchmarkDotNet.Artifacts/results/

See details in docs:

Package and License

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.1.0 106 3/14/2026
1.0.0 99 3/12/2026
1.0.0-rc.3 133 6/8/2024
1.0.0-rc.2 100 6/8/2024
1.0.0-rc.1 124 5/24/2024