Skip to content

Quick Start

quyvu edited this page Oct 13, 2026 · 2 revisions

Quick Start

Get up and running with FxMap in under 5 minutes using FluentAPI-based configuration.

1

Install Required Packages

dotnet add package FxMap
dotnet add package FxMap.EntityFrameworkCore
dotnet add package FxMap.RabbitMq

2

Define a Distributed Key

A distributed key is the shared contract between the entity config and the DTO profile:

public sealed class UserDistributedKey : IDistributedKey;

3

Configure Your Entity

Use EntityConfigureOf<T> to expose entity data:

public class UserConfig : EntityConfigureOf<User>
{
    protected override void Configure()
    {
        Id(x => x.Id);
        DefaultProperty(x => x.Name);
        UseDistributedKey<UserDistributedKey>();
        ExposedName(x => x.Email, "UserEmail");
    }
}

4

Define a Profile for Your DTO

Use ProfileOf<T> to declare which properties to auto-populate:

public class UserResponseProfile : ProfileOf<UserResponse>
{
    protected override void Configure()
    {
        UseDistributedKey<UserDistributedKey>()
            .Of(x => x.UserId)
            .For(x => x.UserName)
            .For(x => x.UserEmail, "UserEmail");
    }
}

5

Register FxMap Services

Configure FxMap in Program.cs:

builder.Services.AddFxMap(cfg =>
{
    cfg.AddEntitiesFromAssemblyContaining<SomeEntityAssemblyMarker>();
    cfg.AddProfilesFromAssemblyContaining<SomeProfileAssemblyMarker>();
    cfg.AddRabbitMq(config =>
    {
        config.Host("localhost", "/", 5672, c =>
        {
            c.UserName("guest");
            c.Password("guest");
        });
    });
})
.AddEntityFrameworkCore(options =>
    options.AddDbContexts(typeof(AppDbContext)));

6

Use IDistributedMapper

Inject IDistributedMapper and call MapDataAsync:

var response = new UserResponse { UserId = "user-123" };
 
// FxMap auto-populates all declared properties
await mapper.MapDataAsync(response);
 
Console.WriteLine(response.UserName);  // "John Doe"
Console.WriteLine(response.UserEmail); // "john@example.com"

You're all set!

FxMap will automatically:

  • Discover all EntityConfigureOf and ProfileOf classes in the registered assemblies
  • Batch all lookups for the same distributed key into a single request
  • Populate all declared profile properties using compiled expressions

Source: https://fxmapper.net/docs/quick-start/ — the website is always the most up to date version.

Clone this wiki locally