Save same changes to multiple databases RRS feed

  • Question

  • Hi
    I'm looking to build a configuration application using LightSwitch for some static data in multiple SQL databases with the same table structure. I want to be able to pick up the data from one "primary" database, and apply my changes to all other databases.

    I though something along the lines of using the SaveChanges_Executing method to replicate the changeset.
    I know I can change the connection string during run-time, and get the ChangeSet, but I'm not sure how to create another DataService, provide it a different connection string (prompt SVMData_InitializingConnection), and copy all changes by either copying changeset or iterating on all changes in changeset and applying them one by one.

    I can't use any solutions on the database side such as mirroring.


    Wednesday, January 7, 2015 11:34 AM

All replies

  • Hello

    I know that you said you cannot use any database solutions but does that include Triggers on the tables? I am sure that you can do what you are looking to in LS but I know that it'll be a lot easier to do a trigger on the SQL Table that will just insert\update\delete the records in the other databases\tables for you and will not cause you a large overhead on the User front end.



    If you found this post helpful, please mark it as helpful. If by some chance I answered the question, please mark the question as answered. That way you will help more people like me :)

    Wednesday, January 7, 2015 12:13 PM

  • Thanks for the quick reply Otis,
    Unfortunately no, I can't use any triggers or other database solutions (such as replication).

    • Edited by Eli Passov Thursday, January 8, 2015 6:40 AM
    Thursday, January 8, 2015 6:40 AM

  • Thanks for the quick reply Otis,
    Unfortunately no, I can't use any triggers or other database solutions (such as replication).

    HI Eli,

    As Otis mentioned above, you can try replication on your side.

    At the same time you can also data mashup to save to Multiple Data Sources in the HTML Client, you can connect to multiple data sources, configure virtual relationships between entities in different data sources, and then visualize all of the data at the same time. Such as:

    myapp.onsavechanges = function (e) {

        var personData = myapp.activeDataWorkspace.DemoServiceData;

        e.detail.promise = personData.saveChanges()

            .then(function () {

                var profileData = myapp.activeDataWorkspace.ApplicationData;

                return profileData.saveChanges();



    More resource: Saving to Multiple Data Sources in the HTML Client

    Best regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Edited by Angie Xu Saturday, January 31, 2015 8:55 AM
    Saturday, January 31, 2015 8:54 AM