Answer the question
In order to leave comments, you need to log in
How to change DTO in a project?
Hello, I have a project with various DTO, ViewModel, classes. I've looked at a lot of sites but never got the right answer. I need to change my DTO, but if I just add a new field there, nothing happens. Should I roll the migration due to a change in the DTO (after all, this is only done when the model changes, and this is not quite a model, as I understand it) or should I do something else?
Answer the question
In order to leave comments, you need to log in
When changing the DTO, there will be no migration, as you correctly noted, this does not change the entity.
Entity is mapped to the database (attributes or fluent annotations), and its changes already require migration.
Entity is also mapped to DTOs, either by hand or by frameworks (like AutoMapper).
It turns out that you forgot to register a new field in the Entity -> DTO mapping. Since it was not picked up automatically, then the DTO field name is different from the field name in Entity or manual mapping there.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question