How to Use Entity Frame work With XML field's in Relational Database RRS feed

  • Question

  • Hi ,

    I want to make a n-tier application with ado.net Data services . but i have a big problem .

    I have a Database that Contains a Table with xml Data . this Table have Six columns .



    --> intPersonID (int)

    --> xmlContent (xml)

    --> dtmLastModified (datetime)

    --> dtmCreationDate (datetime)

    --> intCreatorID (int) 

    --> intLastModfierID (int) 



    In the xmlContent Field I Have Three Node Like This :


    Code Snippet



       <FullName>jfk lop</FullName>





    <Email type="private">



    <Email type="public">






    <Address type="Home"> every where may I raom . <Address>

    <Address type="Work"> every where may I raom 2 . <Address>










    I want To Generate an Entity Model for This xml field and Crud Operation Like The Relational Databases .


    so , How can I generate and Modify on this xml filed ?

    Any Idea ?


    Thanks .


    Saturday, September 27, 2008 8:45 AM


  • Unfortunately the EF does not support promoting parts of an XML column up as direct properties of an entity.  You can have an XML column as a property, but the property is treated as a string rather than having the EF map into the XML.  Building deeper integration with XML is something we've talked about for a future release but don't yet have a firm plan of when it will arrive.


    One thing you could consider doing is creating a view on your database which uses functions in the DB to expose parts of the XML as columns in the view and then use stored procedures to handle inserts, updates and deletes.  The EF could then be mapped to the view and the stored procedures.


    - Danny


    Sunday, September 28, 2008 2:58 AM