❔ Advice on Data modeling-ef core
Basically I've got a lesson which is an aggregate root, On said lesson i got phases and each phase has an answer.
I want to be able to save past answers aswell to analyze.
Current Code:
So I've come up with 2 approaches:
1.A phase will contain a list of answers and we will only load the last added to the db when making calls, Was unsure how to do it and Chat-gpt gave me this:
2.create a new entity named pastAnswer that sits on Phase, but doesnt load it except for when we want to load it for something
And when the user submits a new answer, it gets saved as a past answer, and the new answer becomes the user answer
3 Replies
Guys? 😮
so do you want to add a new record into the table when you change the entity, instead of overwriting it with the new value. Is this what you mean?
probably better done with a custom abstraction, or a change interceptor
there you could check for phases and mark it as new instead of updated
first do it in the simplest waybpossible
query
FirstOrDefault
from the list, and then set the entity to new in the change tracker
and maybe reset the id, depends on your model configWas this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.