Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
I create sample wcf rest application using entity framework database first approach.I want to serialize and deserialize entity objects to xml format.I am able to serialize with custom classes instead of using Entity classes but unable to serialize and deserialize entity objects (like Person, PersonEmails).
My XML format like below
XML
<person>
<name>XXX</name>
<personemails>
<personemail>
<email>test@abc.com</email>
<personemail>
</personemails>
</person>

Here PersonEmails is the navigation property of Person Entity

Anybody help me how to do this using entity objects.

Thanks in advance.
Posted
Updated 26-Jan-14 23:49pm
v3

1 solution

You cannot do this.B'cos we cannot do serialization the EF navigational properties.

So here you have to create Plain Old Class Object(POCO)(i.e. custom class) and after that assign your navigational property values into that and then use those plain objects (which are only having the primitive data types) for your mapping.

What is POCO ?
 
Share this answer
 
v4
Comments
ponnapureddy 27-Jan-14 6:34am    
Thanking you for your help..and i have one question i.e,
I created POCO classes by using POCO generator for existing edmx file still xml serialization and deserialization not working. Is there any other way to use EF classes without to create Custom classes.

Thank you.
Sampath Lokuge 27-Jan-14 6:40am    
After that what is the status of 'PersonEmails' navigational property ? Which way you used it with the xml ? Is that still a navigational property or collection of primitive data types ? can you pot that code snippets also (ie. poco classes and final usage of xml).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900