Quantcast
Channel: EntityFramework Reverse POCO Code First Generator
Viewing all articles
Browse latest Browse all 1642

Commented Feature: Make use of db comments to aid with data annotations [56]

$
0
0
As emailed to me by Fatih Yücel ŞEN <fatihyucelsen@hotmail.com>

When reading the database schema, also read the column __comments__ for each field.
This could be in the format of:
```
field=value;field=value;...
```

For example of column __comments__:
* name=Currency code;req=3 digit currency code is required;max=3
* email=true
* password=true

Gives:
* [Display(Name = "Currency code")]
[Required(ErrorMessage = "3 digit currency code is required")]
[StringLength(3, ErrorMessage = "Must not exceed 3 characters")]

* [DataType(DataType.EmailAddress)]
[RegularExpression(@\"[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

* [DataType(DataType.Password)]

Attachment is based on v2.4.1 code
Comments: Trouble is, the generator is already using column comments to document the generated schema. See the use of IncludeExtendedPropertyComments, and the enumeration ExtendedPropertyCommentsStyle. Let's see if this feature requrest gets more votes.

Viewing all articles
Browse latest Browse all 1642

Trending Articles