Page 1 of 1

XML Ignore EntityKey

Posted: Wed 24 Mar 2021 10:13
by idkomfs
Hello, how can i ignore the EntityKey (see below) druring XML-Serialization?

<custs>
<cust>
<EntityKey>
<EntitySetName>mdmsqryMT2CADIAdr</EntitySetName>
<EntityContainerName>mdmsEntities</EntityContainerName>
<EntityKeyValues>
<EntityKeyMember>
<Key>AdrNr</Key>
<Value xsi:type="xsd:int">10017</Value>
</EntityKeyMember>
</EntityKeyValues>
</EntityKey>

<data1>
</data1>
<data2>
</data2>
...
</cust>
</custs>


Thanks for help
regards

Re: XML Ignore EntityKey

Posted: Fri 26 Mar 2021 14:45
by Shalex
Solutions:

1. With the EntityObject template, enable also the Data Transfer Objects template to convert entities into DTO-objects. Then, serialize DTO-objects.

2. Use the DbContext template instead of a default EntityObject template not to generate a base EntityObject class. This will avoid the problem with serialization.

Re: XML Ignore EntityKey

Posted: Fri 26 Mar 2021 15:13
by idkomfs
Thank you very much!

I wonder where the Information for the EntityKey came from.
I couldn't find it in the Entity-Object-Class. Is it rendered at Serialize-Runtime?

regards

Re: XML Ignore EntityKey

Posted: Mon 29 Mar 2021 15:59
by Shalex
The DataMember attribute is defined for EntityKey by Microsoft: https://docs.microsoft.com/en-us/dotnet ... mework-4.8.