Site icon 峰哥分享

A wield mongodb serialization issue caused by hidden property

This line throw exception.
Here is the exception detail

The problem is caused by 

The reason to use the new keyword is to hide the Name property in the base calss which has a required attribute. The new keyword will override the require attribute so that Name will not be validated.
The name in base class is hidden, but when mongo does serialization, it will found two names, so it causes the problem. The error message is confusing anyway. It's nothing to do with Id.