Power tools : Data annotations for reverse engineering instead of fluent


In many applications, having the classes generated use Data Annotations instead of the Fluent mapping is more desirable. There are blog posts on how to customize the tt files to do this for some things, but not all...For example, Key, Foreign Key, Required, MaxLength and relationships. Please make this an option.
Closed Feb 13 at 1:52 AM by jemartti
Fixed as part of OneEF.


RoMiller wrote Sep 18, 2012 at 4:57 PM

Our plan is to provide code generation templates for Fluent API and Data Annotations and have a dropdown that allows you to pick which one you want.

RoMiller wrote Sep 25, 2012 at 5:56 PM

When we merge the Power Tools and EF Designer we should look at making Data Annotations the default.

Robar wrote Jul 10, 2013 at 10:32 AM

Are there any updates on this issue? I'm currently creating the data annotations on my own, but this is quite cumbersome if there are many tables with a bunch of relationships.

jmanning wrote Aug 27, 2013 at 8:01 PM

While the templates miss some cases currently, you can try some of the template sets in this repo: https://github.com/jamesmanning/EFReverseEngineerCodeFirstTemplates

Also, a promising project (also available as VS extension) in terms of replacing this (which, IMHO, might be nice for the EF team to help out with?) is the separate reverse engineer project @ https://efreversepoco.codeplex.com/

RoMiller wrote Dec 12, 2013 at 9:17 PM

We are doing this as part of the 'Tooling Consolidation' in 6.1

AndreZiegler wrote Dec 13, 2013 at 5:32 AM

Don't use annotations, Fluent API is much better :( :'(

paully21 wrote Dec 13, 2013 at 3:46 PM

Thanks Rowan!

BriceLambson wrote Dec 26, 2013 at 7:13 PM

Fixed in my private repo.