I would like to know how to add a property to an entity object from my model.
[EdmEntityTypeAttribute(NamespaceName="MyObjectModel", Name="MyObject")]
[Serializable()]
[DataContractAttribute(IsReference=true)]
public partial class MyObject: EntityObject
{
private int myVar;
public int MyProperty
{
get { return myVar; }
set { myVar = value; }
}
}
When I do this, the new property doesn’t appear in MyObject but i don’t get any error.
How should I proceed to do this ?
Thanks !
As I see the
EdmEntityTypeAttributeattribute, I assume you’re modifying theDatabasemodel.Designer.csfile. As the header of this file says:this file is auto-generated and must never be manually modified. So your property is basically removed when this file is re-generated (probably on compilation).
Just create a new file to add your property:
For example,
MyObject.cs:Do note that the
partialkeyword is designed to allow separating the definition of a class in multiple files.