Repository navigation
Home
An Object-Graph Mapper (OGM) for .NET — like Entity Framework, but for labelled-property graphs. You declare CLR types as nodes and edges, the framework owns an identity map and a queue of pending changes, and SaveChanges translates them into provider-native statements wrapped in a transaction.
public sealed class BlogGraphContext(GraphContextOptions options) : GraphContext(options)
{
protected override void OnModelCreating(IGraphModelBuilder builder) => builder
.ApplyConfiguration(new AuthorConfiguration())
.ApplyConfiguration(new PostConfiguration())
.ApplyConfiguration(new WroteConfiguration());
}
// Composition root
services.AddGraphContext<BlogGraphContext>(builder =>
builder.UseNeo4j(new Uri("bolt://localhost:7687"), AuthTokens.Basic("neo4j", "password")));
// Usage
Author ada = new() { Id = Guid.NewGuid(), Name = "Ada Lovelace", JoinedAt = DateTimeOffset.UtcNow };
Post post = new() { Id = Guid.NewGuid(), Title = "Notes on the Analytical Engine", PublishedAt = DateTimeOffset.UtcNow };
context.Nodes<Author>().Add(ada);
context.Nodes<Post>().Add(post);
context.Edges<Wrote>().Connect(ada, new Wrote { WrittenAt = DateTimeOffset.UtcNow }, post);
await context.SaveChangesAsync();
Post[] adasPosts = [.. context.Traversal.Match()
.Node<Author>("a").Where(a => a.Id == ada.Id)
.RelatedBy<Wrote, Post>("w").Outgoing().To("p")
.Return<Post>("p")];-
A typed consumer surface.
GraphContext,Nodes<T>(),Edges<T>(), a fluent traversal builder. Your domain model stays plain CLR types. - A provider-agnostic abstraction. The same context code targets Neo4j, Apache AGE on Postgres, ArangoDB, or an in-process in-memory store. Add your own provider by implementing five interfaces.
-
Change tracking with identity map.
Add,Update,Remove,Mergequeue against a pending queue;SaveChangesflushes them atomically. Auto-flush on no-ambient-transaction; explicitBeginTransactionwhen you need to coordinate. -
OpenTelemetry-compatible diagnostics. ActivitySource spans for
SaveChanges, transactions, statement execution, and traversal translation, plus counters for flush outcomes and per-provider statement counts. PII-disciplined (counts, kinds, modes — never values).
A GraphContext is the entry point. OnModelCreating registers your nodes and edges with their key configuration. Nodes are CLR types with a key property; edges connect two nodes and optionally carry their own properties. Provider extensions (UseNeo4j, UseAge, UseArango, UseInMemory) wire up the concrete translation pipeline. Reads come through Nodes<T>().FindById(...), Exists(...), AsEnumerable(), or the fluent traversal builder. Writes are queued via Add/Update/Remove/Connect/Disconnect and flushed by SaveChanges / SaveChangesAsync.
- Architecture: Abstractions — the consumer surface, the provider contract, the model, the traversal AST.
- Architecture: Implementation — change tracker, transaction factory, lifecycles, diagnostics.
- Provider: Neo4j and MemGraph — Cypher-over-Bolt.
- Provider: Apache AGE — Cypher-over-Postgres.
- Provider: ArangoDB — AQL-over-HTTP (the framework's first non-Cypher provider).
- Provider: In-Memory — in-process store for tests and demos.
- Example: A minimal movie graph — a complete, runnable example app.
github.com/onix-labs/onixlabs-dotnet-element-framework. The repository deliberately ships only agents.md (AI-agent onboarding) and README.md (project README) in the working tree — all the deep documentation lives here.