Question

I've deploy my database through ADO.net Entity Data Model by executing its diagram output query against my pre-made online database.

My database contains Only Lightswitch supported relations, One-Many, ZeroOne-Many & One-ZeroOne.

Finally, Attaching my database to my Lightswitch application as an external database and I was shocked by its result.

Lightswitch converts ALL One-ZeroOne relations to One-Many relations!

I suspect everything, retry tens of times trying to figure this strange issue out with no good news!

Question:

Why Lightswitch converts ALL One-ZeroOne relations to One-Many relations? Inconsistency!

Was it helpful?

Solution 2

Finally, I've solved it by a brute-force-like trials :S


Solution : ( Please don't ask me a WHY question as IDK will be my answer )

After adding a One-to-ZeroOne Relation you might have one or two Navigation Properties added to associated tables, but

  1. You MUST add a Foreign Key as Scalar Property to the ZeroOne Table with Same type & true Nullable properties.

  2. You MUST adjust the Residential Constrain for the association by double clicking the association line itself and make the FK in the ZeroOne Table dependent on the One table Key.

  3. Generate the database script, execute it and Don't Update LightSwitch data source, Delete data source & Attach it again instead as it won't update relations correctly!

OTHER TIPS

Unless this is a bug, it would depend on the nullablility of your PK/FK. LightSwitch will not allow 0-1 for any key property that is not nullable.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top