Rask.Data
0.21.1-alpha.0.9
See the version list below for details.
dotnet add package Rask.Data --version 0.21.1-alpha.0.9
NuGet\Install-Package Rask.Data -Version 0.21.1-alpha.0.9
<PackageReference Include="Rask.Data" Version="0.21.1-alpha.0.9" />
<PackageVersion Include="Rask.Data" Version="0.21.1-alpha.0.9" />
<PackageReference Include="Rask.Data" />
paket add Rask.Data --version 0.21.1-alpha.0.9
#r "nuget: Rask.Data, 0.21.1-alpha.0.9"
#:package Rask.Data@0.21.1-alpha.0.9
#addin nuget:?package=Rask.Data&version=0.21.1-alpha.0.9&prerelease
#tool nuget:?package=Rask.Data&version=0.21.1-alpha.0.9&prerelease
Rask.Data
A data layer for Entity Framework Core apps with one goal: you declare models, and that is all.
No DbContext class, no DbSet property, no IEntityTypeConfiguration, no registration — and no
IDbContextFactory injected into everything that reads a row. Underneath it is ordinary EF Core, and
Db.Current is the real DbContext whenever you want it.
Model<TId>— a base entity withId, audit stamps (CreatedAt/UpdatedAt), and a domain-events buffer. A source generator finds every one of them and builds the model, so nothing is scanned or reflected and a trimmed publish cannot quietly drop a table.- The model type is its own
DbSet—Product.Where(...),Product.FindAsync(id),Product.Add/Update/Remove(...),Product.CountAsync(). C# 14 static extension members, so an entity that compiles today has them. Reads are no-tracking by default and open no context until they run. Db.Begin()— one short-lived ambientDbContextper unit of work, committed by a singleSaveChangesAsync. Nesting joins rather than nests, soawait entity.SaveAsync()inside a caller's transaction takes part in it instead of committing half of it.- Value objects (
IValueObject) map as EF complex types, not owned entities; strongly-typed ids get a generated value converter with nothing declared; mapping rules live in a plainpublic static void Configure(EntityTypeBuilder<T>)on the model. TestDatabase.StartAsync— a real database for a test in one line, so behaviour on a model is tested against the database it ships on rather than a mockedDbContext.- Opt-in markers — implement
ISoftDeletable(addsDeletedAt) orIVersioned(adds aVersionconcurrency token) on your entity to turn on the behavior. - Three
ISaveChangesInterceptors — auditing timestamps, transparent soft delete (aRemovebecomes aDeletedAtstamp behind a global query filter), and after-commit domain-event publication through Rask.Cqrs. BulkInsertAsync— the bulk insert EF Core leaves out (ExecuteUpdate/ExecuteDeleteexist; inserts are out of its scope). Batched, with the change tracker cleared as it goes so memory stays flat.
Use
public sealed class Product : Model<Guid>, ISoftDeletable, IVersioned
{
public string Name { get; private set; } = "";
public DateTime? DeletedAt { get; private set; }
public int Version { get; private set; }
public static Product Create(string name) => new() { Id = Guid.NewGuid(), Name = name };
}
// read — no context in scope, nothing left open
var active = await Product.Where(p => p.DeletedAt == null).OrderBy(p => p.Name).ToListAsync();
// write — one transaction over everything it touches
await using var uow = Db.Begin();
Product.Add(Product.Create("Anvil"));
Product.Remove(discontinued);
await uow.SaveChangesAsync();
In a Rask app that is the whole of it — the host builds the model and points the ambient database at it. Elsewhere, name the context once and hand it over after the container is built:
builder.Services.AddRaskCqrs();
builder.Services.AddRaskData<AppDbContext>();
builder.Services.AddDbContextFactory<AppDbContext>((sp, o) => o
.UseSqlite("Data Source=app.db")
.AddInterceptors(sp.GetServices<ISaveChangesInterceptor>()));
var app = builder.Build();
Db.Configure(app.Services);
A class that does not derive from Model stays an ordinary EF Core entity: write your own context
and configurations and use them exactly as before. Registering an IDbContextFactory<YourContext> is
the whole of opting out at the app level.
db.Remove(product) now soft-deletes; deleted rows drop out of queries (use IgnoreQueryFilters() to
restore); a save against a stale Version throws DbUpdateConcurrencyException; and any
INotification raised on the entity is published after the change commits.
To load many rows at once — seeding, an import, a migration — await db.BulkInsertAsync(products) (or
db.Products.BulkInsertAsync(...)) saves them in batches, clearing the change tracker between each so memory
stays flat. The interceptors above still run for every row. Each batch commits on its own so a long import
does not hold SQLite's only write lock end to end; o.SingleTransaction = true makes it all-or-nothing.
For the fastest load, o.SkipChangeTracking = true writes the rows with one prepared INSERT and no entity
entries at all. It is opt-in because it runs no ISaveChangesInterceptor — the writer stamps the audit
columns itself, but entities carrying domain events are rejected rather than silently losing them, and
anything it cannot map faithfully throws and names the reason.
Non-overlapping ranges
A booking, a lease, a price valid for a period: two rows must not cover the same point. SQLite has no
EXCLUDE constraint and a UNIQUE index only stops identical rows, so declare the rule on the model
instead:
modelBuilder.Entity<Booking>()
.HasNonOverlappingRange(x => x.StartsAt, x => x.EndsAt, partitionBy: x => x.RoomId);
Ranges are half-open ([lo, hi)), so 100-200 and 200-300 are neighbours rather than a conflict. With
Rask.SQLite.EntityFrameworkCore's UseRaskSqlite(...), migrations emit the triggers that enforce it and a
violating save throws RangeOverlapException. Enforcement lives in the database, so raw SQL is bound by it
too.
Part of the Rask framework. MIT licensed.
| 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
- Microsoft.EntityFrameworkCore (>= 10.0.12)
- Microsoft.EntityFrameworkCore.Relational (>= 10.0.12)
- Rask.Cqrs (>= 0.21.1-alpha.0.9)
NuGet packages (3)
Showing the top 3 NuGet packages that depend on Rask.Data:
| Package | Downloads |
|---|---|
|
Rask.SQLite.EntityFrameworkCore
The Entity Framework Core integration for Rask.SQLite: `UseRaskSqlite(...)`, a drop-in replacement for `UseSqlite` that also registers a `ConnectionOpened` interceptor applying the production pragma set (WAL, `synchronous=NORMAL`, `foreign_keys=ON`, a `busy_timeout`, `mmap_size`, `journal_size_limit`) to every connection the context opens. Split out from Rask.SQLite so apps that only need the raw `Microsoft.Data.Sqlite` path (or run on mobile/AOT) don't pull in Entity Framework Core. |
|
|
Rask.Outbox
A transactional outbox for Rask.Data entities: domain events marked `IOutboxEvent` are written to an `OutboxMessage` table in the **same transaction** as the change that raised them (so an event is never lost and never fires for a rolled-back change), then a background `OutboxProcessor` polls the table and publishes them through Rask.Cqrs — at-least-once, crash-safe delivery, all on the app's own database (no broker, no Redis). A source generator registers each event type for reflection-free lookup. Server-side; pairs with Rask.Data. |
|
|
Rask
The one reference a Rask application needs, server or browser. On net10.0 it brings the ASP.NET host plus every battery — database, mediator, background jobs, transactional email, cache, outbox, operator dashboard, durable logs, Web Push, and SQLite snapshots and continuous backup — with RaskApp.Create(args) as the entry point. On net10.0-browser it brings the WebAssembly host, the source-generated mediator, the query cache and remote dispatch. Everything referenced is wired and on; app.Configure(c => c.Jobs.Off()) is how an app does without one. Reference Rask.Server for a lean host with no database. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 0.21.1-alpha.0.30 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.29 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.28 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.27 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.25 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.23 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.22 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.20 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.19 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.18 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.17 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.16 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.14 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.12 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.11 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.10 | 0 | 9/11/2026 |
| 0.21.1-alpha.0.9 | 19 | 9/10/2026 |
| 0.21.1-alpha.0.6 | 26 | 9/10/2026 |
| 0.21.1-alpha.0.5 | 26 | 9/10/2026 |
| 0.21.1-alpha.0.2 | 27 | 9/10/2026 |