I want to create a custom property on one of my entities mapped from the database, however this property is not mapped to the database, I created the property using partial
I'm seriously late to the conversation, but you also want to mark the partial as serializable and the property as serializable - if you ever plan to JSON or serialize the objects:
[Serializable()]
public partial class MyClass {
private System.Nullable _Age;
[global::System.Runtime.Serialization.DataMemberAttribute(Order = 4)]
public System.Nullable Age {
...
}
}
Both the [Serializable()] and the [global:] directives are needed. If you excluded the [global:], any time you serialized it, it'd be ignored and not included in the serialization.