Insert Multiple records with Identity columns in single transaction ? RRS feed

  • Question

  • HI,

    I have 10 different tables in one entity. I need to insert the records in those tables in single transaction. All tables are related with any one of the table.

    All tables are having identity value.

    How can i insert the record in all tables in a using transactionscope ?

    Thanks, Karikalan N
    Monday, September 19, 2011 8:32 AM


  • Hi,

    If you have an Aggregate structure (that is, a root entity and a set of related entities), if you save the main entity, all changes aplied to their related entities should be saved too. Including their corresponding identities fields.

    Here you have an example that should work in your same case:

    Remember to apply properly attributes in your EDMX model, if you are using it:


    Best regards,

    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 solución de esta pregunta te ha sido útil.
    • Marked as answer by Larcolais Gong Monday, September 26, 2011 2:11 AM
    Monday, September 19, 2011 8:57 AM