This project has moved and is read-only. For the latest updates, please go here.

Problem with Entity Framework serialization

Apr 23, 2012 at 12:11 PM

If I generate entites in the edmx from the DB, the attributes each Navigation Property gets automatically are:

that means that soap and xml serialization will not serialize them, and it's good for my case.

But when I use JSON.NET it looks for JsonIgnoreAttribute which not created automatically, and therefor it serialize them.
What I did in order to not change the edmx file and add there JsonIgnoreAttribute  (because each change in the designer will delete those changes),
is go to DefaultContractResolver.cs and change:
bool hasJsonIgnoreAttribute = JsonTypeReflector.GetAttribute<JsonIgnoreAttribute>(attributeProvider) != null

to this:
bool hasJsonIgnoreAttribute = JsonTypeReflector.GetAttribute<XmlIgnoreAttribute>(attributeProvider) != null
so will serialize according to the xml ignore attributes.

Is there other way to do it than change the source code of

Thank you