How to Design Model at runtime? RRS feed

  • Question

  • Hi, it's probably not a good place to ask such this question but really I don’t know any where more suitable to ask my question?

     Any way

    I'm working on a simple code generator, I want to let user to design his model at run time,

    I found that Entity Framework’s model is generated by EntityModelCodeGenerator

     So do you think there would be any way to open EntityModelCodeGenerator at runtime to design an edmx model?

    Tuesday, May 10, 2011 5:29 PM


All replies

  • Hi,

    If I understand you at all, try to take a look to this other thread :



    JA Reyes.

    Please remember to Vote & "Mark As Answer" if this post is helpful to you.
    Por favor, recuerda Votar y "Marcar como respuesta" si la solucion de esta pregunta te ha sido útil.
    Wednesday, May 11, 2011 11:54 AM
  • Hi Reyes and thanks for your replay,

    It seems that I should go throw more detail about my situation,

    as I said I'm working on a code generator program :

    All the code that will generate is depend on a model which developer should design first,

    So I need to open EntityModelDesigner at run time to let user design his model,

    If you think It's impossible let me know

    thank you again


    Wednesday, May 11, 2011 1:03 PM
  • Hello Hamid,

    Thanks for your post.

    Actually, Entity Framework doesn't expose a mutable metamodel, i.e. you cannot alter the model using metadataworkspace at runtime. 

    You do have the ability to alter the metamodel by reading the model into an xmlreader, modifying it and writing it out with xmlwriter.

    Here’s a similar thread like yours. Please check it.


    Hope this helps. If I misunderstood, please feel free to let me know.



    Have a nice day,

    Jackie Sun [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Proposed as answer by Jackie-Sun Thursday, May 19, 2011 2:46 AM
    • Marked as answer by Hamid Moghadam Sunday, May 22, 2011 5:43 AM
    Wednesday, May 18, 2011 2:32 AM
  • As an alternative to reading/writing XML directly, I have a wrapper library that can be used for generating (or modifying) EDMX metadata at runtime. I have written more about that in this blogpost: http://huagati.blogspot.com/2010/12/creating-or-modifying-entity-framework.html , and the documentation/help for the wrapper library is here: http://huagati.com/edmxtools/help/ The library itself ships together with my add-in ( http://huagati.com/dbmltools/ ).

    Note that for inhouse use you can use it if you have a license for the add-in, for redistribution with your own apps a separate redistribution license is needed. This is described in more detail here: http://huagati.blogspot.com/2011/01/redistribution-licenses-for.html

       Cool tools for Linq-to-SQL and Entity Framework 4:
     huagati.com/dbmltools - Visual Studio add-in with loads of new features for the Entity Framework and Linq-to-SQL designers
     huagati.com/L2SProfiler - Runtime SQL query profiler for Linq-to-SQL and Entity Framework v4
    • Proposed as answer by Jackie-Sun Thursday, May 19, 2011 2:46 AM
    • Marked as answer by Hamid Moghadam Sunday, May 22, 2011 5:42 AM
    Wednesday, May 18, 2011 10:49 AM