Lightswitch Multiple relation paths - Cascade rules, entity framework RRS feed

  • Question

  • My question to the developers or LS team is, how are the relations handled in Lightswitch for cascade and update rules?

    For example lets say there are two relation paths,



    There must be PROJECT-> DATA -> ITEMS, but the PO is optional.

    If the cascade rules want to constrain deletion of anything containing items in both paths, Lightswitch will not be able to use that schema for the project.

    I am wondering if by keeping the relationship, but changing the cascade and update rules to be optional for one path will be reflected in Lightswitch when updating the schema so that both relations can exist?

    Thanks in advance

    Thursday, January 16, 2014 4:40 PM


All replies

  • lightswitch cascade delete can help you on this.

    Friday, January 17, 2014 9:29 AM
  • Thanks sharpLj, this topic is pretty useful.

    But for the sake of the question I asked this is not the answer. I am asking if the rule affects whether a
    "loop" in the relationships will be created or not for integrity purposes.

    For example, using my example above, I could use a non-cascade rule for the PO, then use a trigger to update the related ITEMS if a PO is to be deleted (rare situation). The relationship would be one-to-0..1 for PO, and 1-M for DATA.

    I know this works in the database level, but I am curious how Lightswitch handles this situation... I may just try this myself on a test server and post the results.

    Monday, January 20, 2014 5:48 PM
  • I tested setting the cascade paths. The path with the data had a cascade path for deletion, where as the other path was only for update or no action.

    It turns out that it only picked up one relation and not the other, but I am still testing to see if there is a way to do this...

    EDIT: Cascades can be used when defined in the database. However, it does not solve the problem with the multiple relation paths that I described in the topic that I provided a link to in the post below.
    • Edited by agmarkis Thursday, February 6, 2014 8:43 PM
    Thursday, January 30, 2014 10:57 PM
  • When using two pathways, they do not throw any errors in the database.

    However, when updating the datasource, it only takes one of the relations. I am using a composite key (not my choice), and the field that is common (the PROJECT as listed in my example) is not available to be chosen. This is probably because there is already a link being used for it.

    I also have all of the relations with no cascade or delete rules now, but I am still unable to link this data, and I'm trying to think of ways that I can have this data in an editable grid, and I can't think of anything!


    So I tested using surrogate keys instead of composite keys, and it seems to fix this issue. I posted a thread here:


    • Edited by agmarkis Thursday, February 6, 2014 7:44 PM
    • Marked as answer by agmarkis Thursday, February 6, 2014 8:44 PM
    Friday, January 31, 2014 9:37 PM