DynamicEndpoints.EntityFrameworkCore 0.4.0

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

DynamicEndpoints.EntityFrameworkCore

Entity Framework Core persistence for DynamicEndpoints: runtime-defined HTTP endpoints for ASP.NET Core. With it, endpoint definitions survive restarts and are shared by every instance of your application.

License: MIT

Use your own DbContext

public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
    protected override void OnModelCreating(ModelBuilder modelBuilder) =>
        modelBuilder.ApplyDynamicEndpointsConfiguration(); // DynamicEndpoints, DynamicEndpointRevisions, DynamicEndpointDrafts
        // or: modelBuilder.ApplyConfiguration(new DynamicEndpointRecordConfiguration("endpoints", "api"));
}

builder.Services.AddDbContext<AppDbContext>(o => o.UseNpgsql(connectionString));
builder.Services.AddDynamicEndpoints().UseEntityFrameworkStore<AppDbContext>();

Create the tables with your migrations as usual (dotnet ef migrations add AddDynamicEndpoints). Upgrading from 0.3, the history and draft tables are new: add a migration, or call ApplyDynamicEndpointsConfiguration(history: false) to go without them. .MigrateOnStartup<AppDbContext>() applies them on start-up if you want that.

…or the bundled context, with its own migrations

builder.Services.AddDynamicEndpoints()
    .UseEntityFrameworkStore(o => o.UseNpgsql(connectionString), migrateOnStartup: true); // DynamicEndpointsDbContext

The migrations have no provider-specific column types, so they work with SQL Server, PostgreSQL, SQLite, MySQL, … A table created earlier with EnsureCreated is adopted into the migration history. If you'd rather migrate in your deployment pipeline, leave migrateOnStartup off and call Database.MigrateAsync() on DynamicEndpointsDbContext there.

Save endpoints together with your own data

var changes = manager.BeginChanges(db.GetDynamicEndpointStore());   // tracked by db, not saved
await changes.UpsertAsync(definition, ct);
db.FeatureVersions.Add(version);
await db.SaveChangesAsync(ct);                                      // one SaveChanges, one transaction
await changes.ApplyAsync(ct);                                       // now the routes change

If you drop the change set instead of saving, nothing is routed. A stale revision fails inside your SaveChanges with DbUpdateConcurrencyException. If you use explicit transactions, manager.BeginChanges(HttpContext.RequestServices) saves through your scoped DbContext, inside db.Database.BeginTransactionAsync().

Your entities as CRUD endpoints: ef-crud

builder.Services.AddDynamicEndpoints()
    .AddEntityFrameworkCrud<AppDbContext>(crud => crud
        .Entity<Product>(e => e                       // "products" – the DbSet property name
            .Fields(p => p.Id, p => p.Sku, p => p.Name, p => p.Price)
            .ReadOnly(p => p.CreatedAt)
            .Filterable(p => p.Name, p => p.Price)
            .Sortable(p => p.Name)
            .TenantColumn(p => p.TenantId)
            .Operations(CrudOperations.All & ~CrudOperations.Delete))
        .Entity<Order>("orders", e => e.AllFields(except: o => o.InternalNote)));

Admins then build list, get, create, update, patch and delete endpoints on those entities – "processor": "ef-crud", "processorConfig": { "entity": "products", "operation": "list", "pageSize": 50, "sort": "name" } – or scaffold all of them from the EF model (POST /scaffold/crud?entity=products&dryRun=true in the admin API, Scaffold CRUD in the panel, IDynamicCrudScaffolder in code).

  • Allowlist: only exposed entities and fields; definitions store the entity name, never a type. Request bodies are never bound to entities – only declared body parameters that are writable fields are written. Keys, generated values, concurrency tokens, shadow properties and the tenant column are read-only; navigations are never exposed. AllFields() also exposes properties added later.
  • Lists: page/pageSize with a maxPageSize, sorting and filters (eq, ne, lt, lte, gt, gte, contains, startsWith, in) on allowlisted fields only, built as expression trees with parameters.
  • Concurrency: ETag from the concurrency token, If-Match on update, patch and delete (412, 428 with requireIfMatch).
  • Tenants: TenantColumn(…) filters every query by the endpoint's (or request's) tenant and stamps new rows; entities without one are for shared endpoints only, unless SharedAcrossTenants() or AllowTenants(…).
  • Hooks: IDynamicCrudInterceptor<TEntity> in DI, before and after create, update and delete, can reject with validation errors.
  • Code: DynamicEndpoint.Get("/products").HandledByCrud<Product>(CrudOperation.List, c => c.PageSize = 20).

📖 CRUD on EF Core entities

How it is stored

  • Columns: the searchable fields (method, route, name, enabled, version, timestamps).
  • JSON: the full definition, so the definition model can grow without schema migrations.
  • Concurrency: Version is a concurrency token, so a stale write from another instance or admin is rejected.
  • History and drafts: one row per revision (DynamicEndpointRevisions) and per draft (DynamicEndpointDrafts). A revision is saved in the same SaveChanges as the definition it belongs to, and a publish removes its draft in it too.
  • Providers: any EF Core relational provider works (SQL Server, PostgreSQL, SQLite, MySQL, …).

📖 Documentation · 📝 Changelog

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
0.4.0 134 10/2/2026
0.3.0 99 10/2/2026
0.2.0 105 10/1/2026
0.1.2 104 10/1/2026
0.1.1 116 10/1/2026
0.1.0 104 10/1/2026