2

Is it possible to auto generate the POCO classes and the mapping with the database defined separately using Fluent API (instead of annotations) for an existing database? Instead of coding all these entity classes manually, I find it easier if they are auto generated and then I can change them as required if the names are not incorrect (plural or singular) or the some of the relationships are not correctly mapped etc. This will save lot of time for me compared to coding all the entity classes and relationships from scratch and I am not that familiar with the fluent API syntax as well.

RKP
  • 5,285
  • 22
  • 70
  • 111

2 Answers2

1

The Power tools are incredibly slow to generate files. It takes over an hour to work on my companies database (has a lot of tables).

Instead take a look at this visual studio extension http://visualstudiogallery.msdn.microsoft.com/ee4fcff9-0c4c-4179-afd9-7a2fb90f5838

It generates cleaner code, WCF serialisation classes, and includes the database default constraints as part of the POCO ctor.

Disclaimer: I should mention that I am the author of this extension

Simon Hughes
  • 3,534
  • 3
  • 24
  • 45
1

Yes, i encourage you to use Entity Framework Power Tools CTP1

Reverse Engineer Code First - Generates POCO classes, derived DbContext and Code First mapping for an existing database.

hope this helps

dknaack
  • 60,192
  • 27
  • 155
  • 202
  • Thanks for the quick reply, before I use this tool, does this give me an option to separate the config from the entity classes (using fluent API)? I want to keep my classes clean from any database related stuff (metadata). – RKP Nov 29 '11 at 20:52
  • @RKP did you used this tool? How was it? I'm thinking on using it and would like to know your thoughts. – Felix Martinez Dec 08 '11 at 14:35
  • I haven't used it yet and will post my feedback once I use it. even if it isn't perfect, if it reduces some coding effort, that's enough for me. – RKP Dec 08 '11 at 16:03