Having data annotations automatically added to properties

Discussion of open issues, suggestions and bugs regarding Entity Developer - ORM modeling and code generation tool
Post Reply
johnwest80
Posts: 27
Joined: Thu 09 Jun 2011 22:32

Having data annotations automatically added to properties

Post by johnwest80 » Thu 13 Jun 2013 18:34

I'm dumb. There, I said it. I can't find the setting to have data annotation attributes added to my object properties when updating my model from the database. I have two projects in my solution, both with a model within them. For a test, I added a new table to each database called TestTable, with a property called "Name". The model in project A does create the following attributes on the properties:

Code: Select all

        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        [System.ComponentModel.DataAnnotations.Key]
        [System.ComponentModel.DataAnnotations.StringLength(50)]
        [System.ComponentModel.DataAnnotations.Required()]
        public string Name
The model in project B does not...

Code: Select all

        [EdmScalarPropertyAttribute(EntityKeyProperty=true, IsNullable=false)]
        [DataMemberAttribute()]
        public string Name
I know this has got to be something simple. But I have the System.ComponentModel.DataAnnotations v4.0.0 added to each model's attributes list.

What am I missing?

Thx for the help. I know I'm going to feel stupid when you tell me :).

johnwest80
Posts: 27
Joined: Thu 09 Jun 2011 22:32

Re: Having data annotations automatically added to properties

Post by johnwest80 » Thu 13 Jun 2013 18:45

So I found the setting in the XML file.

<ValidationFramework>DataAnnotations</ValidationFramework>

Where is this setting in the UI? Thx.

Shalex
Site Admin
Posts: 8241
Joined: Thu 14 Aug 2008 12:44

Re: Having data annotations automatically added to properties

Post by Shalex » Tue 18 Jun 2013 14:38

Please open the model, select your template in Tools > Entity Developer > Model Explorer and set its Validation Framework property to Data Annotations. Save the model (press F7 in a standalone Entity Developer) to regenerate the code.

Post Reply