0

I would like to export to xml entities with child entities. For example Person and Car. That would be the first step and the second would be to somehow export only subset of all fields and child entities for example: person has a entity car and cat but I would like to export only person and car as a child node.

I'm using DataContractSerializer but I get an error:

Type 'System.Data.Entity.DynamicProxies.DataPerson' with data contract name 'DataPerson:http://schemas.datacontract.org/2004/07/System.Data.Entity.DynamicProxies' is not expected. Consider using a DataContractResolver if you are using DataContractSerializer or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to the serializer.

marc_s
  • 704,970
  • 168
  • 1,303
  • 1,425
Snorlax
  • 717
  • 1
  • 7
  • 16
  • 1
    Show some code please? By the looks of the error you need to give your main model a `DataContract` or `KnownType(otherType)` attribute. – Alexander Derck Apr 08 '16 at 07:03
  • Some code could help. Also maybe take a look at this? http://stackoverflow.com/questions/6234290/serialize-entity-framework-object-with-children-to-xml-file – David Oesterreich Apr 08 '16 at 21:50

0 Answers0