New Posts New Posts RSS Feed: StringLengthVerifier attribute with CF Migration
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

StringLengthVerifier attribute with CF Migration

 Post Reply Post Reply
Author
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Topic: StringLengthVerifier attribute with CF Migration
    Posted: 20-Mar-2012 at 3:36am
Hi,

In the doc http://drc.ideablade.com/xwiki/bin/view/Documentation/code-first-entity-classes it is recommended to use the StringLengthVerifier attribute with CF class.

The problem is this attribute is totally ignored while using CF Migration. So I find myself having to duplicate those information in the Fluent API to be sure the fields will have the required size etc ...

Is this a bug or a normal behavior ?  I can't imagine duplicate this information on all the entities ...


regards 
Back to Top
DenisK View Drop Down
IdeaBlade
IdeaBlade


Joined: 25-Aug-2010
Posts: 715
Post Options Post Options   Quote DenisK Quote  Post ReplyReply Direct Link To This Post Posted: 20-Mar-2012 at 3:19pm
Hi Walid,

Do you mean that the StringLengthVerifierAttribute gets ignored when you run the "Add-Migration" command from your Package Manager Console?

If so, this is expected and outside of DevForce control as Add-Migration is an Entity Framework method and as such it can only recognize the attributes that it knows. And I'm guessing it only recognize attributes listed in Code First Data Annotations.

If you want to use DevForce Verifier attributes, and if it were me, I would do the following steps:

1. Use EF Code First attributes first to build the migration scaffolding
2. Run migration and update the database
3. Use DevForce Code Second to help generate the new entities and their properties complete with DevForce Verifier attributes.

It's not quite as straightforward but it's an option. Hopefully someone smarter than me can chime in :)


Edited by DenisK - 20-Mar-2012 at 3:22pm
Back to Top
Walid View Drop Down
Senior Member
Senior Member
Avatar

Joined: 14-Nov-2010
Posts: 161
Post Options Post Options   Quote Walid Quote  Post ReplyReply Direct Link To This Post Posted: 21-Mar-2012 at 1:55am
Thank Denisk, 

I will investigate your solution.

That might also help me solving my problem with CF Migration and the need of multiple Model, because actually I can't find the best way to do it !!



Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down