EF 4 POCO method

May 31, 2012 at 3:59 PM
Edited Dec 9, 2013 at 2:24 PM
Hy Fabian Fernandez,

Thank you again for this application, but i think it's now obselete and i will explain why :

Now with EF 4 we can use POCO instead of Entities, you create the edmx file then convert it to DbContext , so you will have DBcontext object for persistance that use POCO object auto generated.

But when you do this the edmx files does not contains any entities any more (converted to POCO) !!! so you can't use EntitiesToDTOs
The best pattern i think is : Entity framework with DbContext ,POCO object  and a generic repository for DAL and BLL and DTO(viewmodels, datacontracts) for views, wcf ....

To create DTO, you have to code them or duplicate the code of POCO object (especially in CRUD application)
To convert POCO to DTO you can use AutoMapper or extension methods (ToDTO,ToPOCO)

So i think a good new feature for your utility, is to generate DTO from POCO and generate the assemblers   


Regards
Riadh
Coordinator
Jun 1, 2012 at 2:31 AM

Hello Gomri.

Thanks for your comments and for using EntitiesToDTOs.

I think the tool is not obsolote at all, at least until nobody uses EF Model-First or Database First, right?

I agree with you in some points.

First of all I have to say that POCO approach has at least 3 years now (released in 2009 if I'm right).

POCO is another approach to separate your entities from how you persist them and yep, you are right, if you use DTOs you end up with duplicated classes that only differ by name so creating DTOs would be useless, but that is up to you and your business needs, if you have like 10 entities but only want to expose as DTOs a couple of them, it won't hurt to have a separated assembly with those and get them in sync using EntitiesToDTOs (with a new feature for POCO).

So don't panic people with "obsolete" or "useless" please, the tools is still pretty good at with it does and I hope you find it useful.

Remember, not every project is good for the same approach.

If you think that it would be good to have a "POCO to DTO" feature, please, feel free to request it in the Issue Tracker.

 

Thanks again,
Fabian Fernandez

Marked as answer by ffernandez on 12/30/2013 at 6:56 PM
Jun 1, 2012 at 7:52 AM
Edited Dec 9, 2013 at 2:22 PM
Hi Fernandez, 
I meant by obselete and useless that it can't work with the POCO EF and DbContext 
And since the DbContext + POCO  aapproch is the new recommended way i hope you will add this feature :)  
Thanks 
Riadh