I am using v5.5.185 of ED.
I want to customise the "Required" validation message. The property is marked up as "Required". I went into "Attributes" for Diagram, Class and Property level and selected the "Required" data annotation, specified the "Error Text". Diagram and Class values caused a compile error in VS2012. Only specifying the error message at property level work.
However I also noted that this causes a "Duplicate" "required" annotation error in VS, until I specified that this property was not required by unchecking the required checkbox in the ED property editor. This worked, but it now looks as if this property is not required, unless one looks deeply into attributes for the custom "Required" attribute error message. Is this an issue with ED, or its design?
So what is the best method to implement custom "required" messages. It seems that you can only define the property has "Required" validation, but not what the message is.
Thanks,
How to add a custom "Required" message? Is there an issue here?
Re: How to add a custom "Required" message? Is there an issue here?
There are two ways to add attributes via interface of Entity Developer:
1. Validation Framework
a) open Tools > Entity Developer > Model Explorer > the Templates node, select your template, navigate to its properties:
-> set the Validation Framework property (e.g., to Data Annotations)
-> open Validation Error Messages and specify the text for Required Message
b) set Validate Required=True for a particular class property
2. Custom Attributes
a) navigate to Model > Settings > Attributes > select the assembly with the needed attributes and make sure that the needed attributes are checked in the window below, press OK
b) select the needed attribute in the Attributes collection of a particular class property
The [1] approach is easier to use. If [1] doesn't cover your needs, you can add attributes in the way which is described in [2].
1. Validation Framework
a) open Tools > Entity Developer > Model Explorer > the Templates node, select your template, navigate to its properties:
-> set the Validation Framework property (e.g., to Data Annotations)
-> open Validation Error Messages and specify the text for Required Message
b) set Validate Required=True for a particular class property
2. Custom Attributes
a) navigate to Model > Settings > Attributes > select the assembly with the needed attributes and make sure that the needed attributes are checked in the window below, press OK
b) select the needed attribute in the Attributes collection of a particular class property
The [1] approach is easier to use. If [1] doesn't cover your needs, you can add attributes in the way which is described in [2].
Seems like you employed the Required attribute using [1] and [2] approaches simultaneously.EdB wrote:However I also noted that this causes a "Duplicate" "required" annotation error in VS
Re: How to add a custom "Required" message? Is there an issue here?
Ok, Thanks for this. Will try out.