views:

47

answers:

2

I guess when I generate the entities, they don't have [DataContract] attribute, so I cannot pass the object to client.

+1  A: 

You should use a WCF Data Service, OData, or RIA services, depending upon what you're doing. As you haven't mentioned that, this is all the help I can give.

Craig Stuntz
I will search them. Thank you.
Alan
A: 

DataContract attribute is not needed since .NET 3.5. When you do not mark classes with DataContract, Serializable, etc. default serialization will be used. It means all public properties with getter and setter will be serialized. But in case of EF it should generatee classes with DataContract and DataMember attributes. In this case it is needed because EF generates object graph with circulate references so EF classes have to be marked with [DataContract(IsReference=true)].

Ladislav Mrnka