Alan
Alan

Reputation: 189

.NET - How can I use Entity Framework (Data Entity Model) to a WCF Project?

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

Upvotes: 0

Views: 150

Answers (2)

Ladislav Mrnka
Ladislav Mrnka

Reputation: 364399

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)].

Upvotes: 0

Craig Stuntz
Craig Stuntz

Reputation: 126587

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.

Upvotes: 1

Related Questions