AutoMapperLite
A lightweight, customizable object-to-object mapping library for .NET. Simplify DTO and entity mapping with fluent profiles, nested-property support, and flexible configuration — without the overhead of a full AutoMapper installation.
Created and maintained by Atik Hassan. Versions prior to 4.4.1 are deprecated — see the changelog.
Features
Zero-config auto-mapping
Auto-maps same-named, same-type properties with no configuration.
Nested mapping
Map nested objects and nested List<T> properties whose item types have a registered map.
Fluent profiles
ForMember and ForPath for custom and deeply-nested member mapping, similar to AutoMapper.
Collections
Map to List<T>, arrays, or common collection interfaces (IList<T>, ICollection<T>, IReadOnlyList<T>, IEnumerable<T>), item by item.
DI-friendly
AddAutoMapperLite(Assembly) registers IMapperConfig and IMapper as singletons.
Thread-safe
Configuration and mapping can both be used concurrently.
Installation
Install the NuGet package in your project:
dotnet add package AutoMapperLite --version 4.4.1
Targets net6.0, net7.0, net8.0, net9.0, and net10.0.
Quick Start
1. Register AutoMapperLite in your DI container
using System.Reflection;
var builder = WebApplication.CreateBuilder(args);
// Register all profiles from the executing assembly
builder.Services.AddAutoMapperLite(Assembly.GetExecutingAssembly());
var app = builder.Build();
2. Create a mapping profile
Define your mappings by creating a class that inherits from Profile
and overrides Configure:
using AutoMapperLite;
using AutoMapperLite.Interfaces;
public class MyMappingProfile : Profile
{
public override void Configure(IMapperConfig config)
{
// Basic map: same-named, same-type properties auto-map for free.
config.CreateMap<Country, CountryViewModel>();
// ForMember/ForPath functions must return the ALREADY-MAPPED value,
// not the raw source sub-object — the library never implicitly
// converts types inside a custom mapping function. When source and
// destination property types differ, map through the mapper itself.
var mapper = new Mapper(config);
config.CreateMap<Organization, OrganizationViewModel>()
.ForMember(dest => dest.CountryViewModel,
src => mapper.Map<CountryViewModel>(src.Country));
config.CreateMap<Location, LocationViewModel>()
.ForPath(dest => dest.OrganizationViewModel.CountryViewModel,
src => mapper.Map<CountryViewModel>(src.Organization.Country));
}
}
3. Inject and use the mapper
public class MyService
{
private readonly IMapper _mapper;
public MyService(IMapper mapper)
{
_mapper = mapper;
}
public LocationViewModel GetLocationViewModel(Location location)
{
return _mapper.Map<LocationViewModel>(location);
}
}
Quick answers
Is AutoMapperLite free and open source?
Is AutoMapperLite thread-safe?
CreateMap) and mapping itself (Map) are safe to use concurrently.How does AutoMapperLite compare to AutoMapper or Mapster?
Where next
Getting Started
Install the package and register it with dependency injection in a few lines.
Guide
Mapping, configuration, collections, nested objects, and dependency injection in depth.
API Reference
Full signatures for IMapper, IMapperConfig, MapBuilder<TSource,TDestination>, Profile, and the DI extension method.
Examples
Runnable examples: basic mapping, custom members, deep nested paths, collections, and nested collection properties.
Performance
Real, measured benchmark numbers for the mapping hot path.
Contributing
How to build, test, and submit changes.