I'm using an Entity Framework data model to drive a Dynamic Data website for use by users to update data.
One of the entities contains a non-nullable string property (Description). In the database, one of the rows has an empty Description (not null but an empty string). When I try to update the Description I get the following validation error: "This property cannot be set to a null value". If I manually update the Description in the database and then edit the property, it works as expected. But as soon as I change the Description in the database back to an empty string, the validation error occurs. The error happens on Description's setter.
So I've tried adding an additional string property called CustomDescription which basically wraps Description, made Description a ScaffoldColumn(false) in the entity's metadata and added the new property to the entity's metadata.
[ScaffoldColumn(true)]
public string CustomDescription
{
get { return this.Description; }
set {
if (value == null)
{
value = string.Empty;
}
this.Description = value;
}
}
However what do I need to add to this property in order to get it to display on the dynamic data site?