Repository navigation
Basic Configuration
Learn how to configure FxMap in your application with the essential setup steps to get started quickly.
The first step is to register FxMap services in your application's dependency injection container. Add this to your Program.cs file:
using FxMap;
builder.Services.AddFxMap(cfg =>
{
// Register entity configs from your assembly
cfg.AddEntitiesFromAssemblyContaining<SomeEntityAssemblyMarker>();
// Register DTO profiles from your assembly
cfg.AddProfilesFromAssemblyContaining<SomeProfileAssemblyMarker>();
});FxMap needs a data provider to fetch data. Choose the one that matches your database technology.
For SQL databases using EF Core
builder.Services.AddFxMap(cfg => { ... })
.AddEntityFrameworkCore(options => options.AddDbContexts(typeof(TestDbContext), typeof(OtherDbContext)...)});For NoSQL databases using MongoDB
builder.Services.AddFxMap(cfg => { ... })
.AddMongoDb(cfg => cfg.AddCollection(memberSocialCollection));For microservices architectures, add a transport to enable cross-service communication.
builder.Services.AddFxMap(cfg =>
{
// Other configurations
cfg.AddRabbitMq(config =>
{
config.Host("localhost", "/", 5672, c =>
{
c.UserName("guest");
c.Password("guest");
});
});
})builder.Services.AddFxMap(cfg =>
{
// Other configurations
cfg.AddNats(c => c.NatsOpts(opts => opts.Url = "nats://localhost:4222"));
})Here's a complete configuration example combining all the essential parts:
using FxMap;
var builder = WebApplication.CreateBuilder(args);
// Add FxMap services
builder.Services.AddFxMap(cfg =>
{
// Register entity configs from your assembly
cfg.AddEntitiesFromAssemblyContaining<SomeEntityAssemblyMarker>();
// Register DTO profiles from your assembly
cfg.AddProfilesFromAssemblyContaining<SomeProfileAssemblyMarker>();
cfg.AddRabbitMq(config =>
{
config.Host("localhost", "/", 5672, c =>
{
c.UserName("guest");
c.Password("guest");
});
});
})
.AddEntityFrameworkCore(options => options.AddDbContexts(typeof(TestDbContext), typeof(OtherDbContext)...)});
var app = builder.Build();
app.Run();Your FxMap configuration is now set up! The framework is ready to:
- Discover EntityConfigureOf and ProfileOf classes from registered assemblies
- Connect to your data source
- Enable cross-service communication (if transport configured)
- Automatically map data using your FluentAPI profiles
Remember: All FxMap packages (FxMap, FxMap.EntityFrameworkCore, FxMap.RabbitMq, etc.) must have the same version number to ensure compatibility.
Source: https://fxmapper.net/docs/basic-configuration/ — the website is always the most up to date version.
Introduction
Getting Started
Configuration
- Service Registration
- Entities & Profiles
- Handlers
- Pipelines
- Strongly Typed IDs
- Error Handling
- Retry Policy
- Supervisor
- Telemetry
- Kestrel (HTTP/2)
- Analyzers
Expressions
- Overview
- Property Access
- Filters, Sorting & Paging
- Functions
- Aggregations
- Projections
- Coalesce & Ternary
- GroupBy
Data Providers
Transports
Integrations
Quality
AI Assistants
Migration
Release Notes