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.

Visual Studio Online – Configuration

Background

What is there not to like about GitHub? Not much.  It is very well supported across all platforms (Linux\Mac\Windows).

It is free; at least as long as your files are created in publicly available repositories.

It is that free angle that Microsoft is trying to attack.  As long as you ‘re OK with maximum number of 5 users, MS will allow you private git repositories.

 

Web Site

Sojourn to http://www.visualstudio.com/en-us.

Sign in

Sign in with an existing Outlook/MSN/hotmail account.

signin

 

Account Creation / Usage

If this is the first time you ‘re going to use VisualStudio online, you will have to create an Account.

Account Creation

Create an account.  It is important what you call your Account name as that will be your URL i.e https://<account-name>.visualstudio.com/

Account Usage

On the other-hand, if you already have an existing account, you should use that one.

Account Member

Keep in mind that if someone has added as a member to their account, you will see them listed here, as well.

Accounts

 

 

Projects and Teams

Once you select an account, you ‘re taken to the next screen, the “Projects and Teams” screen.

ProjectsAndTeams

 

 

User Credentials

User Credentials – Basic Authentication Credentials

Github and quite a bit other Unix\Linux implementations rely on public keys to authenticate users.

Visual Studio online supports the user of normal authentication; using plain username and password.

To set it up, we will do the following

  • Using a web browser, connect to http://www.visualstudio.com/
  • Keep in mind that you need an MSN/Outlook account to connect to visualstudio.com
  • Once connected, access https://app.vssps.visualstudio.com/profile/view?mkt=en-us
  • From the top menu bar access the settings menu by clicking on the wrench wrench icon
  • Access “My profile” window
  • The default tab is the “General” tab
  • Access the “Credentials” tab
  • Click on the “Enable Alternate credentials” hyperlink
  • Designate a secondary username by clicking on the Set hyperlink.
  • Enter & confirm the corresponding password
  • Register your changes by clicking on the “Save Changes” button

Please retrace your steps and confirm that your newly designated secondary account is in place.  As the password is previously confirmed, I will not re-enter it, unless you will like a new one.

 

General

UserProfiles - General

 

Credentials

userprofiles-credentials

 

Credentials – Set

userprofiles-credentials-setusername

 

Credentials – Set – Complete

userprofiles-credentials-setusername-and-password

 

Credentials – Alternate Authentication Credentials – Review

userprofiles-credentials-setusername-review

 

 

 

Create Team Project

As this is a new project, we will go create a new project

The project’s name will be NetstatPS and we have a choice of Git or TFS for the Version Control.  We chose to go with Git for now.

Create a new team project

createATeamProject

Create a new team project – Completed

createATeamProjectCompleted

 

Git Command Line Commands

 

On our local computer, let us “clone the empty repository”.

Instruction

cloneTheEmptyRepository

Change Folder

As the Git command line tool will create a folder matching the project’s name when we issue “Git Clone”, we will note our targeted folder.

Launch  Command prompt shell and navigate to our targeted folder’s parent folder.

Syntax:

cd <folder>

Sample:

cd E:\DanielAdeniji\Sourcecode\Powershell

 

Issue “git clone” command

Syntax:

git clone https://<username>.visualstudio.com/DefaultCollection/_git/<project-name>

Sample:

git clone https://daniel.visualstudio.com/DefaultCollection/_git/NetstatPS 

 

Image:

gitClone

 

Issue “git add” command

Syntax:

git add <source-file>

Sample:

git add netstat.ps1

 

Image:

gitadd

 

 

Issue “git commit” command

Syntax:

git commit

Sample:

git commit

 

Image:

gitCommit

Issue “git push” command

Syntax:

git push origin master

Sample:

git push origin master

 

Image:

gitpush

 

Summary

As I said I love github.  But, if there are some files that you will get into problems placing in the public domain, I ask you consider MS Visual Studio online.

Obviously, you can download and provision your own private Source Control library, as well.

References

References – Git Commands

References – Git – Basic Authentication

  1. Work from Git Command stub
    http://msdn.microsoft.com/en-us/library/dd286572.aspx#setup_basic_auth