The Open-Source Attribute-based Mapping Engine for .NET Ecosystem
OfX streamlines data transformation between services in your microservices architecture. Efficient, extensible, and built for maintainability.
OfX is a lightweight, high-performance, attribute-based data mapping engine designed for the .NET ecosystem. Built to empower developers to manage data transformations across services with clarity, speed, and scalability.
OfX prioritizes developer experience. With minimal setup and an intuitive attribute system, you can map complex data models effortlessly, enabling fast iteration, easy maintenance, and powerful extensibility.
From microservices communication to event-driven architectures, OfX is engineered to support high-load, scalable distributed systems with precision and performance.
Use attributes to map data clearly between services, models, or APIs without complex configurations.
Works out of the box with Entity Framework, MongoDB, GraphQL (HotChocolate), gRPC, Kafka, RabbitMQ, NATS, and more.
Built with caching and reflection optimization to handle large volumes of data with minimal overhead.
Easily extend or customize how mappings behave or how services communicate with minimal effort.
OfX is available on NuGet. Install with .NET CLI:
dotnet add package OfX
Configure OfX in your application:
builder.Services.AddOfX(cfg =>
{
cfg.AddContractsContainNamespaces(typeof(SomeContractAssemblyMarker).Assembly);
cfg.AddNats(config => config.Url("nats://localhost:4222")); // Or gRPC, RabbitMq, Kafka, Nats
});
Define a custom OfXAttribute:
public sealed class UserOfAttribute(string propertyName) : OfXAttribute(propertyName);
Tell OfX which model the attribute applies to:
[OfXConfigFor<UserOfAttribute>(nameof(Id), nameof(Name))]
public sealed class User
{
public string Id { get; set; }
public string Name { get; set; }
public string Email { get; set; }
// Add other properties as needed
}
Use attributes to enrich your model:
public sealed class SomeDataResponse
{
public string Id { get; set; }
public string UserId { get; set; }
[UserOf(nameof(UserId), Expression = "Email")]
public string UserEmail { get; set; }
[UserOf(nameof(UserId))]
public string UserName { get; set; }
}