Entity Framework and WCF Navigation Property

0

I'm trying to implement a WCF service that will return a Model that I also use in the Entity Framework. When the model has a virtual property of navigation for association with another model WCF can not parse the object and ends up returning an error saying that the connection was closed.

When I remove the reference (navigation property) the parse is done successfully and the object is returned.

What is the right way to do this? Can not return a Model directly? How do I deal with these membership properties in WCF?

    
asked by anonymous 23.08.2015 / 02:54

1 answer

0

You tried to remove virtual from the navigation property, when we use the virtual, it indicates that we are doing it with Lazy Loading enabled. It is not very logical to use this concept in Web applications, because in the client we will always need all the data.

This article explains the concept of Lazy Loading in more detail: link

Another factor also commented on in the article above is the proxy usage of the Entity Framework. By default, the Entity Framework creates Proxy classes to perform the conversion of the templates to the database and this hinders the time of serializing the data for transmission via WCF.

Also check this post from the Gringo Stack Overflow: link .

I hope I have helped

    
08.09.2015 / 19:27