Hi
I'm using Database First to create my model with the template 'DbContext'. I want to translate the Error Message provides by the context when i'm calling the 'GetValidationErrors()' (in EF6)
After research, I have seen that i could change messages return by this method in the template by changing the 'Validation Error Messages'. Unfortunately, I don't understand how it works. If i'm writing what I want in the field (for example : Required Message = 'hello') the hello error message is not returned by the method and it's always the 'hard coded error message'.
So can you show me an example on how to change this validation error message for another language ? I will make my program in Multi Language so could you please (if it's not too much) explain me an example for multi language.
Thanks for your helps,
Regards,
Pierre.
Validation Error Messages for Internationalization
Re: Validation Error Messages for Internationalization
Please refer to viewtopic.php?f=30&t=28617. Does this help?
Re: Validation Error Messages for Internationalization
Hi,
Thanks for the answer.
Unfortunately, I'v seen this topic before and it didn't work in my case.
In my template (DbContext), I have choosen the 'Data Annotation' for the validation framework property and I have writen my personnal error message in each Error Message , but no one appears when the error is detected. That's why I'm a little disappointed.
I have another problem with the validate rules on property. When I have a validate property which is not in the property (For example MaxLength is in the property and there is a validate rule for MaxLength, but for MinLength, there is just a validate rule), the validation isn't working. (For example, I have writen '2' for the MinLength, but a length of 1 is accepted).
Maybe I'm not using the validate rule on a property in my model in the right way. It's like my context doesn't care about the devart model.
I also want to know if there is the possibility to access to this metadata by code. I can find the facets of my entity (Nullable, MaxLength, FixedLength,...) but not to the validate rules ?
What can I do to access to the validate rules in my model ?
Best regards,
Pierre
PS : Sorry for my english, I hope I'm enough clearly .
Thanks for the answer.
Unfortunately, I'v seen this topic before and it didn't work in my case.
In my template (DbContext), I have choosen the 'Data Annotation' for the validation framework property and I have writen my personnal error message in each Error Message , but no one appears when the error is detected. That's why I'm a little disappointed.
I have another problem with the validate rules on property. When I have a validate property which is not in the property (For example MaxLength is in the property and there is a validate rule for MaxLength, but for MinLength, there is just a validate rule), the validation isn't working. (For example, I have writen '2' for the MinLength, but a length of 1 is accepted).
Maybe I'm not using the validate rule on a property in my model in the right way. It's like my context doesn't care about the devart model.
I also want to know if there is the possibility to access to this metadata by code. I can find the facets of my entity (Nullable, MaxLength, FixedLength,...) but not to the validate rules ?
Code: Select all
var oc = ((IObjectContextAdapter)context).ObjectContext;
MetadataWorkspace workspace = oc.MetadataWorkspace;
IEnumerable<EntityType> tables = workspace.GetItems<EntityType>(DataSpace.SSpace);
var facets= tables.First().Properties[0].TypeUsage.Facets;
What can I do to access to the validate rules in my model ?
Best regards,
Pierre
PS : Sorry for my english, I hope I'm enough clearly .
Re: Validation Error Messages for Internationalization
Hi,
I have solved my problem and everything works now .
Thanks for the answer,
Pierre.
I have solved my problem and everything works now .
Thanks for the answer,
Pierre.
Re: Validation Error Messages for Internationalization
Thank you for letting us know.