DynamicEndpoints.EntityFrameworkCore
0.3.0
See the version list below for details.
dotnet add package DynamicEndpoints.EntityFrameworkCore --version 0.3.0
NuGet\Install-Package DynamicEndpoints.EntityFrameworkCore -Version 0.3.0
<PackageReference Include="DynamicEndpoints.EntityFrameworkCore" Version="0.3.0" />
<PackageVersion Include="DynamicEndpoints.EntityFrameworkCore" Version="0.3.0" />
<PackageReference Include="DynamicEndpoints.EntityFrameworkCore" />
paket add DynamicEndpoints.EntityFrameworkCore --version 0.3.0
#r "nuget: DynamicEndpoints.EntityFrameworkCore, 0.3.0"
#:package DynamicEndpoints.EntityFrameworkCore@0.3.0
#addin nuget:?package=DynamicEndpoints.EntityFrameworkCore&version=0.3.0
#tool nuget:?package=DynamicEndpoints.EntityFrameworkCore&version=0.3.0
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.
Use your own DbContext
public sealed class AppDbContext(DbContextOptions<AppDbContext> options) : DbContext(options)
{
protected override void OnModelCreating(ModelBuilder modelBuilder) =>
modelBuilder.ApplyDynamicEndpointsConfiguration(); // adds the DynamicEndpoints table
// or: modelBuilder.ApplyConfiguration(new DynamicEndpointRecordConfiguration("endpoints", "api"));
}
builder.Services.AddDbContext<AppDbContext>(o => o.UseNpgsql(connectionString));
builder.Services.AddDynamicEndpoints().UseEntityFrameworkStore<AppDbContext>();
Create the table with your migrations as usual (dotnet ef migrations add AddDynamicEndpoints). .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().
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:
Versionis a concurrency token, so a stale write from another instance or admin is rejected. - Providers: any EF Core relational provider works (SQL Server, PostgreSQL, SQLite, MySQL, β¦).
π Documentation Β· π Changelog
| Product | Versions 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. |
-
net10.0
- DynamicEndpoints (>= 0.3.0)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.12)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.