AutoMapperLite 4.4.1

dotnet add package AutoMapperLite --version 4.4.1
                    
NuGet\Install-Package AutoMapperLite -Version 4.4.1
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="AutoMapperLite" Version="4.4.1" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="AutoMapperLite" Version="4.4.1" />
                    
Directory.Packages.props
<PackageReference Include="AutoMapperLite" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add AutoMapperLite --version 4.4.1
                    
#r "nuget: AutoMapperLite, 4.4.1"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package AutoMapperLite@4.4.1
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=AutoMapperLite&version=4.4.1
                    
Install as a Cake Addin
#tool nuget:?package=AutoMapperLite&version=4.4.1
                    
Install as a Cake Tool

<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.4.1</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.4.1 is the current official release. All prior versions (4.0.2 and earlier) are deprecated — see CHANGELOG.md for release history.

📖 Full documentation (Getting Started, API reference, usage guide, performance, FAQ, comparison): automapperlite.atkhssn.info.


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 ForMember and ForPath for custom member and nested member mappings.
  • Supports collection mapping to List<T>, arrays, and common collection interfaces (IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>).
  • Integration via Dependency Injection (DI) — IMapperConfig and IMapper are 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.4.1

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>, arrays, IList<T>, ICollection<T>, IReadOnlyList<T>, IReadOnlyCollection<T>, IEnumerable<T>).
  • Auto-mapping properties with the same name and compatible types.
  • Custom member mapping via ForMember and ForPath.
  • 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 convention/coercion engine, just CreateMap/ForMember/ForPath compiled into cached delegates per type pair. 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 — see the real, measured comparison.

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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.4.1 121 9/20/2026
4.4.0 121 9/2/2026
4.0.2 130 8/29/2026
3.2.1 306 7/9/2025 3.2.1 is deprecated because it has critical bugs.
3.1.1 364 7/9/2025 3.1.1 is deprecated because it has critical bugs.
3.0.2 372 7/9/2025 3.0.2 is deprecated because it has critical bugs.

AutoMapperLite 4.4.1 — current official release; all prior versions are deprecated.

• Fixed: a ForPath mapping targeting a leaf property that legitimately resolves to
 null (e.g. an optional string) either lost that null to a freshly-constructed
 instance, or — for a leaf type with no public parameterless constructor reachable
 via reflection, most commonly string itself — threw InvalidOperationException
 outright. The nested-path walk tried to descend one segment past the actual leaf;
 only intermediate segments need that.
• Added: same-name nested collection destination *properties* now also accept an
 array (T[]) destination, matching the array support the top-level
 Map<TDestination>(object) API already had since 4.4.0. Previously an
 array-typed nested collection property was silently left unmapped even when a map
 was registered for the item types; it is now populated the same way a List<T>-
 or interface-typed nested collection property already was. Purely additive — no
 existing mapping output changes, since this only fills in a property that was
 previously always left at its default.
• Documentation: corrected several stale claims left over from before the 4.4.0
 mapping-engine redesign — destination construction is described as a compiled
 constructor call (Expression.New) rather than Activator.CreateInstance in the
 guide/FAQ, the home page's comparison FAQ answer no longer claims AutoMapperLite
 trails AutoMapper on collections (it has beaten AutoMapper there since 4.4.0), and
 SECURITY.md's supported-version table no longer references 4.2.x, a version that
 was never published to NuGet (see CHANGELOG.md/CLAUDE.md for the verified publish
 history), and the performance page no longer overstates Activator.CreateInstance's
 elimination (it still backs the interpreted ForPath walk and the untyped
 collection-dispatch fallback, just not the compiled per-property path). No
 code-behavior changes from the documentation fixes.
• No public API breaking changes since 4.0.2.

Previous (4.4.0): mapping engine and performance redesign — each source/destination
type pair now compiles into a cached delegate via System.Linq.Expressions on first
use instead of being interpreted through reflection; added
IMapper.Map<TSource,TDestination>(TSource) and broader collection-destination
support (T[], IList<T>, ICollection<T>, IReadOnlyList<T>,
IReadOnlyCollection<T>, IEnumerable<T>); fixed a collection-loop
interface-dispatch cost, flipping AutoMapperLite from trailing AutoMapper on
collection mapping to beating it at every size from 1,000 items upward. See
docs/performance.html and docs/changelog.html for full measured results and history.