Getting Started

Install AutoMapperLite and register it with dependency injection in a few lines.

1. Install the package

dotnet add package AutoMapperLite --version 4.4.1

Or via the Package Manager Console:

Install-Package AutoMapperLite -Version 4.4.1

Targets net6.0, net7.0, net8.0, net9.0, and net10.0.

Upgrading? 4.4.1 is the current official release. Every version 3.2.1 and earlier is deprecated on NuGet for critical bugs — see the changelog for the full, verified history. There are no public API breaking changes since 4.0.2, so upgrading from 4.0.2 is typically a version-number bump only.

2. 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();

This scans the assembly for Profile subclasses and registers both IMapperConfig and IMapper as singletons — see Dependency Injection in the guide for why singletons are safe here.

3. Create a mapping profile

Subclass Profile and override Configure:

using AutoMapperLite;
using AutoMapperLite.Interfaces;

public class MyMappingProfile : Profile
{
    public override void Configure(IMapperConfig config)
    {
        // Same-named, same-type properties auto-map for free.
        config.CreateMap<Country, CountryViewModel>();
    }
}

4. Inject and use the mapper

public class MyService
{
    private readonly IMapper _mapper;

    public MyService(IMapper mapper)
    {
        _mapper = mapper;
    }

    public CountryViewModel GetCountryViewModel(Country country)
    {
        return _mapper.Map<CountryViewModel>(country);
    }
}

Next

Guide

Custom member mapping, nested objects, collections, and advanced usage.

Examples

Runnable, verified examples for every feature.