문제

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.

도움이 되었습니까?

해결책

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

다른 팁

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top