How to change the serialization mode to unidirecti

2020-04-15 03:58发布

问题:

In an article i have read about changing serialization mode to unidirectional in Linq to SQL, I want to change serialization mode to Unidirectional in entity framework in order to use serialized entity framework objects on client side using WCF service. Guide me please.

回答1:

Entity framework doesn't have such setting. This unidirectional configuration was for Linq-to-sql where it forced code generator to mark each entity with [DataContract(IsReference=true)]. Built-in EF code generator and T4 templates for EntityObjects or STEs do this automatically. If you want to use POCO T4 generator template for class generation you must modify template to mark every entity class with [DataContract(IsReference=true)] and each property with [DataMember].