开发者

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

开发者 https://www.devze.com 2023-01-12 22:53 出处:网络
I guess when I ge开发者_Python百科nerate the entities, they don\'t have [DataContract] attribute, so I cannot pass the object to client.You should use a WCF Data Service, OData, or RIA services, depen

I guess when I ge开发者_Python百科nerate the entities, they don't have [DataContract] attribute, so I cannot pass the object to client.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消