I'm using Automapper to copy one object properties to other and later will update in database using EF.
Question is how to tell Automapper copy every property but ignore a particular property (in this case it will be Id). I'm new to AutoMapper and just have done this code. I don't have other configurations or use of AutoMap in project.
Mapper.Map(lead, existingLead);
I have downloaded AutoMapper form here https://github.com/AutoMapper/AutoMapper
On your Mapper.CreateMap<Type1, Type2>()
you can use either
.ForSourceMember(x => x.Id, opt => opt.Ignore())
or
.ForMember(x => x.Id, opt => opt.Ignore())
UPDATE:
It seems like .Ignore()
is renamed to .DoNotValidate()
according to the AutoMapper docs.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With