C#C
C#4y ago
bookuha

❔ Automapper map Id to Entity

I receive the following DTO (request)

BookDTO{
int Id,
int AuthorId
}

I want the mapper to map AuthorId to the Author entity and put in into the Book.Author.

How do I do this? Should I inject the dbcontext into my profiles?
Or can I simply map Dto AuthorId to Entity AuthorId and it will be fine and navigation will be filled once context is saved?
What is the best way?
Was this page helpful?