LightSwitch – Application Hangs when exiting “Add/Edit Details Screen”

Background

Upon launching an Add/Edit Details Screen and clicking the Save or Discard button, the Application Hangs.

Reproduction Steps

AddEdit Screen / Before Changes

 

addeditservers-guid-20161022-1124pm

 

Add Edit Screen / Post Clicking on Save or Discard Button

Upon clicking the Discard button, the busy ( unfinished circle ) appears…

addeditservers-guid-20161022-1125pm

 

Banged Head

Really banged my head against the wall, it happened every time, I try the things listed below:

  1. Data Changed
    • Clicked Save or Discard button
  2. No Changes
    • Clicked Save or Discard button

Could not reproduce it on other screens and so sought to see what makes this screen unique.

 

Trouble Shooting

Minimal Table

Database

Created a new table with a couple of columns ( sequence, serverName, serverId).

Same problem.

 

Added candidate key

Database

Structure

Use SSMS Database Diagram, here is the original table’s structure…

databasediagram-listofservers

And, so our primary key is on the sequence column.  That column’s datatype is uniqueidentifier.

 

Index

Added Index

ALTER TABLE [dbo].[listofServers] 
	ADD  CONSTRAINT [constraintUniqueServerId]  
		UNIQUE
			(
				[serverID]
			)

Review Indexes

exec sp_helpindex '[dbo].[listofServers]'

 

index

Our unique indexes look like:

  1. PK_listofServers
    • sequence ( Datatype is uniqueIdentifier )
  2. IX_listofServers_ServerName
    • serverName ( Datatype is varchar )
  3. constraintUniqueServerId
    • serverId ( Datatype is int)

 

 

Visual Studio

Solution Explorer

In Solution Explorer, right click on the affecting Data Source and choose the “Update  Datasource” menu item

solutionexplorer-updatedatasource

Add Data Source Wizard

Within “Choose your Database Objects”, review the list of columns, the primary key, and candidate keys…

databaseobject-20161023-1204am

 

Explanation
  1. We see that the sequence column is registered as our Primary Key
  2. We see the other columns
  3. But, we do not see any special distinction for our candidate key column, the serverId column

Click the finish button to effect the DB Changes

 

Data Sources – Entity

Solution Explorer – listofServers.lsml

Within the Solution Explorer, select the entity, in this case listofServers.lsml, and double-click on your sslection.

entity-listofservers

 

Entity – listofServers.lsml

Pasted below are the column names, there datatypes, and required indicator.

Columns

Here are the columns, including the sequence column; marked as the Primary Key ( PK ).

entity-listofservers-columns

Column – serverId

The column, serverId, is listed.

Though in the database it is designed as a candidate key, it is marked any differently.

entity-listofservers-columns-page-2

Entity – listofServers.lsml – Property

Unfortunately, we are not able to manually set the Primary Key columns on the listofServers entity.

Entity – listofServers

entity-listofservers-properties

 

Entity – listofServers – Column – sequence

entity-listofservers-property-sequence

Entity – listofServers – Column – serverId

entity-listofservers-property-serverid

 

Summary

LightSwitch does not give us the ability to override the primary keys specified on the backend database.

 

 Create Tracking View

Let us create a tracking view over the table.  And, if we can designate a primary key on the view.

Database

View Design

Here is our view and we included all columns and we are have not included where nor grouping clauses.

dbo

Add Data Source Wizard

Within “Choose your Database Objects”, review the list of columns, the primary key, and candidate keys…

dbo

Explanation
  1. All not nullable columns are included in the list of primary key columns
  2. And, nullable columns are left out

Click the finish button to effect the DB Changes

 

Data Sources – Entity

Solution Explorer – v_listofServers_UI.lsml

Within the Solution Explorer, select the entity, in this case v_listofServers_UI.lsml, and double-click on your selection.

solutionexplorer-v_listofservers_ui-properties-1259pm

Explanation

The default setting is for Views to be marked Un-editable.

And, this is reflected via the “Is Editable” property to be off.

To designate them editable and to be able to set primary key columns on table, please check the “Is Editable” setting.

 

Solution Explorer – v_listofServers_UI.lsml

Navigate the list of columns for the entity and on each column that should be included in the primary key, please check the “Is Key” property.

entity_v_listofservers_column_serverid_v02

 

LightSwitch Backend

Reviewing the files that LightSwitch generates is also a good way to intimate oneself with the Application.

lsml files

What is lsml?

lsml stands for “LightSwitch Markup Language”.

Folder

For entities, the lsml files are placed in this folder

Naming Convention

<project.Server>\DataSources\<Data Source>

Sample

EDiag.Server\DataSources\DBDiagData

Files

Based on the entities we currently have defined, here are the our generated files

foldersandfiles

Sample Files

listofServers

listofservers_lsml

 

v_listofServers_UI

v_listofservers_ui_lsml

 

Tabulated

Entity
Key Column
Property Type
IsReadOnly Attributes
listofServers
 sequence
 :Guid Required
NotSearchable
v_listofServers_UI
 serverId
 :Int32  Yes  Hidden
Required
NotSearchable

 

 

Version

To pinpoint the version of LightSwitch where we experienced the problem, please use the Help\About menu.

Visual Studio – Version

version-14-0-25431-01-update3

Our Base Product & Version # is

Microsoft Visual Studio Community 2015
Version 14.0.25431.01 Update 3

And, for LightSwitch the Version # is

LightSwitch for Visual Studio 2015

Updates available?

To review the list of available updates, please click on the menu items “Tools“/”Extensions and Updates

Here are the Product Updates that are currently available…

productupdates-20161023-0159pm

As we installed the tools only this week, we do not appear terribly out of alignment in terms of patches.

 

Summary

So we experienced a small usability problem.

Will have to try to reproduce on other machines to determine if it in actual problem.

Also, the more we work with the tool, we hope to get a lot better at localizing problems.

2 thoughts on “LightSwitch – Application Hangs when exiting “Add/Edit Details Screen”

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s