Range Validation in database first

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
figueiredorj
Posts: 36
Joined: Fri 12 Apr 2013 19:05

Range Validation in database first

Post by figueiredorj » Tue 17 Nov 2015 11:05

Hi,

I am working on a database first environment.
For validations we have been including constrains in database and defining some rules(constrains) on it.
However we just noticed that I am unable to fetch validation either as expression or range.

Is there anything I am missing of it really is so?

MariiaI
Devart Team
Posts: 1472
Joined: Mon 13 Feb 2012 08:17

Re: Range Validation in database first

Post by MariiaI » Thu 19 Nov 2015 11:04

If we understood you correctly, you are using validation on the server side and check the data being sent to the database table.

If you want to set such validation directly in the model, you can set the validation rules for entity properties. To do it, please open your model, in the Model Explorer (the Model Explorer can be opened by selecting Model Explorer from the Entity Developer submenu of the Tools menu) select Properties from the context menu of the used template (e.g. DbContext) and set the Validation Framework property, for example, to Data Annotations.
After you have made these changes, select a particular class property on a diagram (or in Model Explorer) and initialize the needed attributes in the Validation section in the Properties window. Save the model to regenerate the code (the code will be regenerated with all necessary attributes).
For example:

Code: Select all

[System.ComponentModel.DataAnnotations.Range(typeof(double), @"0", @"100")]
public virtual global::System.Nullable<double> VALUE
Please refer to the corresponding topic in the Entity Developer documentation: http://www.devart.com/entitydeveloper/e ... eloper.chm > Basic Workflows-> Code generation-> Entity Property Validation.

If this information doesn't help, please send us a test model with the necessary DDL scripts and describe the steps we should follow to reproduce the behaviour.

Post Reply