More advanced AutoMapper examples in .Net Core
AutoMapper is a convention-based, object-oriented mapper. An object-oriented mapper is one that transforms an input object into an output object of a different type. AutoMapper also can be used to map similar or dissimilar objects (i.e., objects having properties that may or may not be identical).
We examined the basic features of AutoMapper in a previous article. In this article we’ll explore some of the advanced features of AutoMapper.
Create an ASP.Net Core project in Visual Studio
First off, let’s create a new ASP.Net Core project in Visual Studio. Note that you can create any project, i.e., MVC or even a Console Application, to work with AutoMapper. If Visual Studio 2019 is installed in your system, follow the steps outlined below to create a new ASP.Net Core project.
- Launch the Visual Studio IDE.
- Click on “Create new project.”
- In the “Create new project” window, select “ASP.Net Core Web Application” from the list of templates displayed.
- Click Next.
- In the “Configure your new project” window shown next, specify the name and location for the new project.
- Click Create.
- In the “Create New ASP.Net Core Web Application” window shown next, select .Net Core as the runtime and ASP.Net Core 2.2 (or later) from the drop-down menu at the top.
- Select “Web Application” as the project template to create a new ASP.Net Core web application.
- Ensure that the check boxes “Enable Docker Support” and “Configure for HTTPS” are unchecked as we won’t be using those features here.
- Ensure that Authentication is set to “No Authentication” as we won’t be using authentication either.
- Click Create.