1
I would like to know if the information I found after searches, which briefly, is in the link below, proceeds:
Question:
In a hypothetical situation, if we have the class Car and the class Brand, where Car has a Brand and Brand may have several Cars (One-to-Many), the Entityframework forces me to create a 'Tag' field in the object Car, or else I would have to carry the whole object Brand at the time of an inclusion/amendment of a Car if I don’t want to use a field Marcaid ?
Reason for the question:
Even in the links where I found this information, they say that this practice hurts OO’s good practices. There is a better solution for these cases?
I edited the excerpt on the question i would have to load the entire Mark object at the time of an inclusion/change of a Car? , I didn’t specify the situation.
– Joaquim Magalhães
@Joaquimmagalhães I edited the answer.
– Leonel Sanches da Silva
Personally I find it very strange! If I have already configured the key of the Tag object, why does EF force me to create a field
MarcaId
instead of usingMarca.Id
. I am changing the model (a representation of a real world concept) for the purpose of meeting the persistence framework. Thank you for the sloppiness and forgive me for the insistence... rs– Joaquim Magalhães
@Joaquimmagalhães Because a Model reflects the database data representation. If for example you have a
DropDownList
on an editing screen and it is based onMarcaId
(assuming, hypothetically, that you can change the brand of the car), it makes no sense to useMarca.Id
. You’d be altering a data ofCarro
, and not ofMarca
.– Leonel Sanches da Silva
I understand. It’s more related to a Model than a Domain of the problem. In this view it makes sense!
– Joaquim Magalhães
MVC with Entity Framework is not strict DDD. It follows some things from the DDD, so much so that we can say that it implements the DDD, but in a more flexible way.
– Leonel Sanches da Silva