Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using AutoMapper in POCO?

I currently have a POCO class in my ASP.NET MVC project that handles all business logic. There are no references to other projects or third-party assemblies.

I am also using AutoMapper in my other projects to facilitate mapping between view models / entities. It is a fantastic tool and saves me considerable time when I make changes to fields on a given entity.

However, within my POCO class are a few segments of code that map between entities. The business purpose is to take entities from one data source and update another data source. Here I am manually mapping and I'm finding it annoying to go in and adjust that mapping when I could employ AutoMapper instead.

Is it a good idea or a bad idea to use AutoMapper in my business logic project? Why?

like image 890
Mayo Avatar asked May 02 '26 10:05

Mayo


1 Answers

'll respond to your question with a question.

Why would it ever be bad to use AutoMapper to map properties? I cannot think of a reason, besides a concern over taking an external assembly reference, that you would not want to use AutoMapper.

like image 73
John Farrell Avatar answered May 03 '26 22:05

John Farrell



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!