AutoMapperLite 4.0.2
See the version list below for details.
dotnet add package AutoMapperLite --version 4.0.2
NuGet\Install-Package AutoMapperLite -Version 4.0.2
<PackageReference Include="AutoMapperLite" Version="4.0.2" />
<PackageVersion Include="AutoMapperLite" Version="4.0.2" />
<PackageReference Include="AutoMapperLite" />
paket add AutoMapperLite --version 4.0.2
#r "nuget: AutoMapperLite, 4.0.2"
#:package AutoMapperLite@4.0.2
#addin nuget:?package=AutoMapperLite&version=4.0.2
#tool nuget:?package=AutoMapperLite&version=4.0.2
<p align="center"> <picture> <source media="(prefers-color-scheme: dark)" srcset="docs/assets/logo-dark.png"> <img src="docs/assets/logo-light.png" alt="AutoMapperLite" width="360"> </picture> </p>
<p align="center"> <strong>v4.0.2</strong> · <a href="LICENSE">MIT License</a> · net6.0 – net10.0 · <a href="https://automapperlite.atkhssn.info">automapperlite.atkhssn.info</a> </p>
AutoMapperLite
A lightweight, customizable object-to-object mapping library for .NET projects. Designed to simplify DTO and entity mapping with easy-to-use profiles, support for nested properties, and flexible configuration — created and maintained by Atik Hassan.
Targets net6.0, net7.0, net8.0, net9.0, and net10.0.
4.0.2 is the current official release. All prior versions (4.0.1 and earlier) are deprecated — see CHANGELOG.md for release history.
📖 Full documentation (Getting Started, API reference, usage guide, performance, FAQ, comparison): automapperlite.atkhssn.info once deployed, or open docs/index.html locally in a browser.
Features
- Simple, lightweight object mapping between source and destination types.
- Supports nested object mapping, including nested
List<T>properties whose item types have a registered map. - Fluent profile-based configuration similar to AutoMapper.
- Supports
ForMemberandForPathfor custom member and nested member mappings. - Supports collection mapping (e.g., List<T>).
- Integration via Dependency Injection (DI) —
IMapperConfigandIMapperare both registered as singletons, since neither holds per-request state. - Thread-safe: mapping configuration and the mapper itself can be used concurrently.
- Designed as a small NuGet package for internal project use.
Installation
Install the NuGet package in your project:
dotnet add package AutoMapperLite --version 4.0.2
1. Register AutoMapperLite in your DI container
In your Program.cs or startup configuration:
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 Mapping Profiles
Define your mappings by creating classes inheriting from Profile and override Configure method:
using AutoMapperLite;
using AutoMapperLite.Interfaces;
public class MyMappingProfile : Profile
{
public override void Configure(IMapperConfig config)
{
// Basic map
config.CreateMap<Country, CountryViewModel>();
// ForMember/ForPath functions must return the already-mapped value, not the raw
// source sub-object — the library does not implicitly convert types for you. When
// the source and destination property types differ (as here: Country vs.
// CountryViewModel), map through the mapper itself inside the function.
var mapper = new Mapper(config);
// Map with ForMember for direct property mapping
config.CreateMap<Organization, OrganizationViewModel>()
.ForMember(dest => dest.CountryViewModel, src => mapper.Map<CountryViewModel>(src.Country));
// Map with ForPath for nested properties
config.CreateMap<Location, LocationViewModel>()
.ForPath(dest => dest.OrganizationViewModel.CountryViewModel, src => mapper.Map<CountryViewModel>(src.Organization.Country));
}
}
3. Inject and Use Mapper
Inject IMapper in your classes and map objects easily:
public class MyService
{
private readonly IMapper _mapper;
public MyService(IMapper mapper)
{
_mapper = mapper;
}
public LocationViewModel GetLocationViewModel(Location location)
{
return _mapper.Map<LocationViewModel>(location);
}
}
API Overview
CreateMap<TSource, TDestination>()
Defines a mapping between source and destination types.
ForMember(destinationMember, sourceFunc)
Configures mapping for a single direct property of the destination object.
- destinationMember: Expression to specify a destination property (e.g.
dest => dest.CountryViewModel) - sourceFunc: Function to select source property/value.
ForPath(destinationPath, sourceFunc)
Configures mapping for nested properties within the destination object.
- destinationPath: Expression specifying a nested destination property path (e.g.
dest => dest.OrganizationViewModel.CountryViewModel.Name) - sourceFunc: Function to select source property/value.
When to use ForMember vs ForPath?
| ForMember | ForPath |
|---|---|
| Maps a direct, single-level property | Maps a nested property several levels deep |
| Use when destination property is top-level | Use when destination has nested complex objects |
| Simpler and direct | Allows mapping into nested objects’ properties |
Supported Features
- Map single objects and collections (
List<T>). - Auto-mapping properties with the same name and compatible types.
- Custom member mapping via
ForMemberandForPath. - Nested object instantiation and mapping.
- DI-friendly registration with extension method
AddAutoMapperLite. - Profiles discovery from assemblies.
Folder Structure
AutoMapperLite/
│
├── Core/
│ ├── Mapper.cs # Core mapper logic and reflection
│ └── MapperConfig.cs # Mapping registry (CreateMap / GetMap / HasMap)
│
├── Mapping/
│ ├── MapBuilder.cs # Fluent mapping configuration builder (ForMember / ForPath)
│ └── Profile.cs # Base Profile class for defining maps
│
├── Interfaces/
│ ├── IMapper.cs # Mapper interface
│ └── IMapperConfig.cs # Mapper configuration interface
│
├── Extensions/
│ └── ServiceCollectionExtensions.cs # DI extension methods
│
├── AutoMapperLite.Tests/ # xUnit test project
├── AutoMapperLite.Benchmarks/ # BenchmarkDotNet benchmark project
├── docs/ # Static documentation site (deploys to automapperlite.atkhssn.info)
│
├── README.md # This documentation file
├── CHANGELOG.md # Release history
├── LICENSE # MIT License
├── CONTRIBUTING.md # Contribution guidelines
├── CODE_OF_CONDUCT.md # Contributor Covenant
├── SECURITY.md # Vulnerability reporting policy
└── AutoMapperLite.csproj # Library project file
Contributing
This package is designed for internal or commercial use in your projects. Feel free to fork, modify, and enhance as needed. Pull requests and suggestions are welcome — see CONTRIBUTING.md for how to get started, and CODE_OF_CONDUCT.md for community expectations.
For reporting security vulnerabilities, see SECURITY.md.
License
AutoMapper Lite is open-source software licensed under the MIT License.
You are free to use, modify, distribute, and use this software commercially, subject to the conditions of the MIT License.
Frequently Asked Questions
Is AutoMapperLite free and open source? Yes — MIT licensed, free for personal and commercial use. See License.
Which .NET versions are supported? net6.0, net7.0, net8.0, net9.0, and net10.0.
Is it thread-safe? Yes — configuration (CreateMap) and mapping (Map) can both be used concurrently; see the concurrency tests in AutoMapperLite.Tests.
How does it compare to AutoMapper or Mapster? AutoMapperLite is intentionally smaller in scope — no LINQ projection support, no runtime IL/expression compilation, just CreateMap/ForMember/ForPath and reflection-based mapping with cached metadata. Choose it when you want a minimal-dependency mapper for straightforward DTO/entity mapping; choose AutoMapper or Mapster for large projects needing LINQ ProjectTo, value converters, or maximum raw throughput.
More questions answered in the full FAQ.
Contact
Project: AutoMapperLite · GitHub
Author: Atik Hassan · atik.hassan@outlook.com
Thank you for using AutoMapperLite! Happy Mapping 😊
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 is compatible. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
-
net6.0
-
net7.0
-
net8.0
-
net9.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
AutoMapperLite 4.0.2 — current official release; all prior versions are deprecated.
• Fixed: updated test tooling (xunit.v3, Microsoft.NET.Test.Sdk 18.9.0) hard-required
net8.0+ and a Microsoft Testing Platform v2 change dropped dotnet test's legacy
VSTest bridge on the .NET 10 SDK — the test project now targets net8.0-net10.0 (the
library itself is unaffected and still targets net6.0-net10.0) and a repo-root
global.json opts dotnet test into native MTP mode
• Fixed: Activator.CreateInstance failures (e.g. mapping to a positional record with
no parameterless constructor) now throw a clear InvalidOperationException naming
the type, instead of a bare MissingMethodException
• Added real, measured BenchmarkDotNet comparisons against manual mapping, AutoMapper
16.2.0, and Mapster 10.0.12 — published in docs/performance.html; AutoMapperLite is
not the fastest of the four, and the docs/package description no longer claim
otherwise
• Verified and documented several previously-untested behaviors: null source
properties are skipped (not assigned), auto-map requires an exact type match
(different enum types / numeric widening are not converted), and records with a
parameterless constructor + init-only properties map correctly
• No public API breaking changes since 3.0.3