© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
19 replies
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?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Model, Dto, Entity - Id?
C#CC# / help
2y ago
✅ EFCore cannot map another entity
C#CC# / help
3y ago
✅ can't map an entity to DB
C#CC# / help
3y ago
❔ ✅ AutoMapper DI
C#CC# / help
3y ago