0
I am trying to implement a WCF service that will return a Model that I also use in the Entity Framework. When the model has a property virtual
from navigation to association with another model WCF cannot parse the object and ends up returning an error saying that the connection has been closed.
When I remove the reference (navigation property) the parse is successfully done and the object is returned.
What’s the right way to do this? Can’t I directly return a Model? How do I deal with these association properties in WCF?
Thiago, good afternoon, I’m the same problem, you got some solution?
– user49154
Good Afternoon Ricardo and Welcome to Sopt, the comments are a field of clarification of doubts, in case you have a question I recommend you ask a new question so that the community can help you directly.
– Guilherme Lima
@Ricardopulini, the
Entity Framework
needs the property to be virtual in order to do theLazyLoading
, but it is not desirable to put the[DataMember]
in a virtual property, in this case, the best thing to do is to create aDTO
and do the Mapping ofEntity
to theDTO
and move on toDTO
.– Tobias Mesquita