none
DTO Generator tool for entity framework

    General discussion

  • Hi there

    I am looking for a DTO generator/addin that will generate the data transfer objects for me from my edmx or csdl file, and it would be able to re-generate the DTO code once the edmx has been altered.  I thought this would be a common tool that many developers would like to have, but I couldn't find one after hours of search on the internet.

    Does anyone know such a product, or interested to write one?

    thanks!
    Sunday, February 22, 2009 12:24 PM

All replies

  • Hi *,

    couldn't help but wonder you spent hours on searching? I think even with XSLT (or RE) you should be able to transform CSDL file into class in couple of hours, using C# and not XSLT in probably half of that time.
    Jiri {x2} Cincura
    Sunday, February 22, 2009 12:43 PM
  •  thanks Jiri

    I have not idea how to do it. Can you please give me little more information? I am not good at xml! During the hours of search, I was also digging on the web to try to get enough information to quickly create a text template file to generate the code. But then i figured it's not that easy specially I want the DTOs to be regenerate whenever the entity modle is altered. Then I thought there must be tools or sample codes on how to generate DTO code from edmx for csld file. This should be quite a common case for developers who work on entity framework and SOA.
    Sunday, February 22, 2009 2:56 PM
  • Hi *,

    maybe there's some tool doing it. Have no idea. But think what you need? Only name of entity, properties and datatypes. All this is in CSDL. If you look at http://blog.vyvojar.cz/jirka/archive/2008/12/07/making-names-of-entities-or-any-identifiers-in-entity-framework-model-code-and-developer-friendly-not-uppercase.aspx you can see how to get similar information, so you only need to change little bit the code. No more than hour. For complex types you have to decide how you will represent it, probably you'll flattern the output. And that's it. You're done. If you have a lot of time, you can tune it for related data handling/loading etc.


    Jiri {x2} Cincura
    Sunday, February 22, 2009 3:18 PM
  • thanks! that is good enough for me at this point. I could use the code sample there at your link to handle the CSLD file I retrieved and use the text template to generate the DTO code.
    Sunday, February 22, 2009 3:40 PM
  • Hi Ivan,

    You can find a simple solution to generate DTO's here:

    http://www.insidelogic.nl/main/Blog/tabid/146/EntryId/4/Create-DTO-Data-transfer-objects-from-an-Entity-Framework-edmx-file.aspx

    Regards,
    Dimitri Stoikof
    Insidelogic
    Sunday, April 05, 2009 5:30 PM
  • Hi,
    I don't know if it's relevant anymore, but i wrote an open source utility, called DTOGenerator, that generate DTO's from ADO.NET Entity Framework model or from LINQ to SQL Data Classes. you can check it out here: http://dtogenerator.codeplex.com  .


    Shahar.
    Thursday, October 01, 2009 5:18 AM
  • I found on good visual item template to create DTOs from entities



    Wednesday, July 20, 2011 2:32 PM
  • Hi Ivan!

    Sorry to arrive 2 years later, I recently published EntitiesToDTOs at CodePlex, it is an Entity Framework DTO generator used as an AddIn for Visual Studio.

    You'll no longer have to create DTOs for all your entities!

    Go to http://entitiestodtos.codeplex.com to get your copy, it is free and open source.

    Features

    • DTOs generation from EDMX file.
    • Support of Entity Types.
    • Support of Complex Types.
    • Support of Nullable Types.
    • Support of all Scalar Types.
    • Support of Entity Associations.
    • All generated classes are partial to allow you to extend them in other source files.
    • No need to modify generated code.
    • You do not need to delete previous generated source files, they will be updated automatically.
    • Logging system allows you to easily report bugs.

     

    Saturday, July 23, 2011 3:53 PM
  • That doesnt work Fabian. I get an error on win 7 saying no access to c:\\*.temp.cs 

    I dont remember the actual file name. All I remember is that it tries to make a file in C:\ drive and when I give full privileges on C drive to all users, it gives another error saying 'The required permission is not held by the client'

    Monday, February 13, 2012 12:52 PM
  • Hello nbl.

    I'm sorry to hear that you are facing an error with EntitiesToDTOs.

    Are you using the latest version (v.2.0) ? If so, then let me know so I will fix the issue tonight because I'm at work right now.

    If you want you can also create a ticket at http://entitiestodtos.codeplex.com in the IssueTracker so you are notified when the issue is resolved. Please, explain all the issue with detail in there also.

    Thanks for using EntitiesToDTOs and for reporting this issue.

    I'm thinking of a workaround: try running Visual Studio with Administrator rights, that could fix the issue by now. But I will fix it so there is no need to do that. Let me know if the workaround works.

    Regards,


    Fabian Fernandez / .NET Software Architect @ raccoon.es / Montevideo, Uruguay.



    Monday, February 13, 2012 1:01 PM
  • Hello again nbl.

    I have fixed your issue in the current development version and it will be added in the next release.

    If the issue is a showstopper for your work I recommend you download the source code, build the solution and grab the .dll generated then drop it on "drive:\Users\{username}\Documents\Visual Studio 2010\Addins\"

    I also will let you know when the release with fix is available.

    Thanks again for reporting that.


    Fabian Fernandez / .NET Software Architect @ raccoon.es / Montevideo, Uruguay.


    Friday, March 02, 2012 5:14 PM
  • When I click on "generate", I get "An error occurred: Object reference not set to an instance of an object."

    I can see all of my edmx files in the source box, but the only thing available in the Target Project box is, "System._ComObject".  Not sure why its not showing the other projects that I have in my solution.  Does this work for VB.Net projects?

    Friday, May 18, 2012 9:25 PM
  • Hello Digga77.

    I'm sorry to hear that you are facing an error, can you report this in:
    http://entitiestodtos.codeplex.com/workitem/list/basic

    Please, if possible, attach the solution you are using at least with dummy classes so you don't reveal your code but the important thing is the project types.

    Also, please take a look the not supported target projects (there are a couple of VB.NET project that are currently not supported):
    http://entitiestodtos.codeplex.com/wikipage?title=Not%20supported%20target%20projects&referringTitle=Documentation

    Thanks


    Fabian Fernandez / .NET Software Architect @ raccoon.es / Montevideo, Uruguay.

    Saturday, May 19, 2012 2:26 AM