AutoMapperMIT.Collection.EntityFrameworkCore
14.0.1
dotnet add package AutoMapperMIT.Collection.EntityFrameworkCore --version 14.0.1
NuGet\Install-Package AutoMapperMIT.Collection.EntityFrameworkCore -Version 14.0.1
<PackageReference Include="AutoMapperMIT.Collection.EntityFrameworkCore" Version="14.0.1" />
<PackageVersion Include="AutoMapperMIT.Collection.EntityFrameworkCore" Version="14.0.1" />
<PackageReference Include="AutoMapperMIT.Collection.EntityFrameworkCore" />
paket add AutoMapperMIT.Collection.EntityFrameworkCore --version 14.0.1
#r "nuget: AutoMapperMIT.Collection.EntityFrameworkCore, 14.0.1"
#:package AutoMapperMIT.Collection.EntityFrameworkCore@14.0.1
#addin nuget:?package=AutoMapperMIT.Collection.EntityFrameworkCore&version=14.0.1
#tool nuget:?package=AutoMapperMIT.Collection.EntityFrameworkCore&version=14.0.1
<img src="https://s3.amazonaws.com/automapper/logo.png" alt="AutoMapper">
AutoMapper.Collection.EntityFrameworkCore
Automapper.Collection.EntityFrameworkCore will help you when mapping an EntityFramework Core DbContext-object.
Configuration examples
- Usage together with Dependency injection and AutoMapper.Extensions.Microsoft.DependencyInjection package
var services = new ServiceCollection();
services
.AddEntityFrameworkInMemoryDatabase()
.AddDbContext<DB>();
services.AddAutoMapper((serviceProvider, automapper) =>
{
automapper.AddCollectionMappers();
automapper.UseEntityFrameworkCoreModel<DB>(serviceProvider);
}, typeof(DB).Assembly);
var serviceProvider = services.BuildServiceProvider();
Note: User defined equality expressions will overwrite primary key expressions.
What about comparing to a single existing Entity for updating?
Automapper.Collection.EntityFrameworkCore does that as well through extension method from of DbSet<TEntity>.
Translate equality between dto and EF object to an expression of just the EF using the dto's values as constants.
dbContext.Orders.Persist(mapper).InsertOrUpdate<OrderDTO>(newOrderDto);
dbContext.Orders.Persist(mapper).InsertOrUpdate<OrderDTO>(existingOrderDto);
dbContext.Orders.Persist(mapper).Remove<OrderDTO>(deletedOrderDto);
dbContext.SubmitChanges();
Note: This is done by converting the OrderDTO to Expression<Func<Order,bool>> and using that to find matching type in the database. You can also map objects to expressions as well.
Persist doesn't call submit changes automatically
How to get it
Use NuGet Package Manager to install the package or use any of the following commands in NuGet Package Manager Console.
PM> Install-Package AutoMapperMIT.Collection.EntityFrameworkCore
| 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 was computed. 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 was computed. 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 was computed. 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 was computed. 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. |
-
net6.0
- AutoMapperMIT.Collection (>= 14.0.1)
- AutoMapperMIT.Extensions.ExpressionMapping (>= 14.0.1)
- Microsoft.EntityFrameworkCore (>= 6.0.36)
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 |
|---|---|---|
| 14.0.1 | 1,888 | 3/18/2026 |