none
Programmatically Compare and Generate EDMX based on the changes in the Database RRS feed

  • Question

  • Hello Everyone,

    I have a requirement where i need your help. 

    Requirement: Programmatically Compare existing EDMX file with the database and if the EDMX file is not up to date with the recent database changes, Generate/Update EDMX file with updated database changes. (Exactly similar as what Visual Studio provides to Update model from database...)

    I tried to look for an object model/api to do that but couldn't find anything so far. Has anyone done this before? Please let me know if you have done this before or you have any idea/approach to take care of this requirement.

    Thanks a lot in Advance!

    -SP

    Wednesday, April 11, 2012 8:01 PM

Answers

  • No, I haven't done that, it's only a tool can help you to modify the edmx file. I don't think synchronous the database and model can be done in the code, the edmx file is written by XML, if you want to compare the structure with database, you have to compare all the XML elements everytime, it will affect the performance seriously. So, i suggest you just update the model from designer when you update the database.

    Fighting like Allen Iverson. Neve give up!

    Friday, April 13, 2012 2:14 AM

All replies

  • Does this help?

    http://huagati.blogspot.com/2010/12/creating-or-modifying-entity-framework.html


    Fighting like Allen Iverson. Neve give up!

    Thursday, April 12, 2012 3:15 AM
  • Did you ever used them to achieve the similar functionality? Do they expose any APIs?
    Thursday, April 12, 2012 2:30 PM
  • No, I haven't done that, it's only a tool can help you to modify the edmx file. I don't think synchronous the database and model can be done in the code, the edmx file is written by XML, if you want to compare the structure with database, you have to compare all the XML elements everytime, it will affect the performance seriously. So, i suggest you just update the model from designer when you update the database.

    Fighting like Allen Iverson. Neve give up!

    Friday, April 13, 2012 2:14 AM
  • Hi sanjay18283,

    Welcome  to MSDN Forum.

    I agree with @Hero. A edmx file is written by XML, it contains SSDL section, CSDL section and MSL section, so, if you have hundreds of entities, the number of element in the xml file is huge. You also have to query the schema of the database before comparing all the elements of the xml file. It's really a big project, every time you do such a work, the performance will be seriously impact.

    Best Regards


    Allen Li [MSFT]
    MSDN Community Support | Feedback to us

    Friday, April 13, 2012 7:05 AM
    Moderator