|
Starting with Visual Studio 2010, when you generate a model from an existing database, the ADO.NET Entity Data Model Designer (Entity Designer) creates scalar properties on entity types that correspond to foreign key columns in the database.
By default, the Entity Designer also generates navigation properties on entity types that can be used to create and modify relationships.
The problem is that this auto generated navigation property are marked with DataMemberAttribute and thus, exposed to the WCF client.
In case you use LazyLoading feature of entity Framework, then data contract serializer will try to serialize WHOLE graph of the objects, resulting in huge amount of data to be transferred to the client.
If you disable LazyLoading, this will reduce the amount of data being transferred to the client. But in this case navigation properties will be still present on the client side, confusing it (If navigation property contains no data, client will not know if there is no data in the DB or property was not loaded by the WCF service).
Therefore, i think in some cases it is really good to exclude Entity Framework Navigation Properties from WCF service contract.
Doing so will allow you to continue to use LazyLoading (i like this) in your WCF service implementation, while clearing client-side object definitions.
There are several possible ways to achieve it. I found the following one to be just right work me
|