OlimilOops
OlimilOops

Reputation: 6797

How to deploy a Lightswitch 2012 app as desktop+local - user connection string

In Lightswitch it is possible to publish the app on the desktop with a local database also on the same computer. In Lightswitch 2012 the publishing wizard asks for a valid user connection string. In Lightswitch 2011 this was more easy because this input was not necessary. In this scenario it was easy to test the login and the users and roles-management.

what is a "valid user connection string", why do I now (compared to LS11) have to input this, where to get information about my right user connection string?

Thanks in advance

PS: of course I already had installed MS SQL Server 2012, nevertheless I reinstalled it again, also SqllocalDB. But it's still the same. when I publish the app, and when I try to start it, it says something like: "Error during communication with the database" .
enter image description here

Upvotes: 2

Views: 4830

Answers (4)

OlimilOops
OlimilOops

Reputation: 6797

I noticed there are many views on this post.

OK since VS 2012 Update 2, in Lightswitch I go with project version 3.

pv1: LS 2011
pv2: VSLS 2012
pv3: VSLS 2012-with project upgrade

Right click your project in project Explorer and from the menu select the menu item "Project-Upgrade"

publishing your project (pv3) to your desktop is very easy again.

I can not give a detailed description in english, because my VS is not english, please have a look at the Microsoft How-To Videos from Beth Massi.

Upvotes: 1

OlimilOops
OlimilOops

Reputation: 6797

In the Lightswitch Publish Application Wizard

  • under Application Type, "Client" select "Desktop"
  • under Applcation Server Configuration select "Locale"
  • under Publish Output enter a directory where your application and setup will be copied e.g. enter "C:\MyProjectname\" and select "Create a script file to install and configure the database"
    Note: (for reasons unknown to me) "Publish directly to the database now" will not work
  • under Database Connections click the button [...]
    in the dialog "Connection Properties", for Servername enter ".\SQLEXPRESS"
    the user connection now could look like:
    "Data Source=.\SQLExpress;Integrated Security=True"
  • under Database Connections also check "Create the SQL database script"
    and select "Create new database with the following name" and leave the suggestion (projectname)

-> Click the button "Publish"

Go to the directory you defined for your app ("C:\MyProjectname\") and start setup.exe.
the database "ApplicationDatabase.mdf" will be created under the folder "Application Files\bin\Data".
Now you can start your app and test the login and the users and roles management screens.

Upvotes: 3

Dave Kidder
Dave Kidder

Reputation: 1848

If you have SQL Express installed on your machine then the server name should be ".\SQLExpress"

If you only have LocalDB installed, the server name should be "(LocalDB)\v11.0"

Upvotes: 6

Ryan
Ryan

Reputation: 635

In lightswitch 2012, when you use the publish wizard you need to specify two connection strings regardless of application type:

  1. User connection: This connection will be used by the application to read and write data from database. In fact this is the connection to production database. If you have enabled built-in security in your app, the target database will contain security related tables as well. You must specify a valid connection string.
  2. Database Schema: If this is the first time your are publishing this app or if you have had database changes, which you would like to be included in this release, you can publish your database schema to your database server by specifying a connection string to database server. Lightswitch will create or update production database for you. This option is not mandatory because you may already have your database ready to go.

Here is a link to have further reading about lightswitch deployment: Distributing and Maintaining Your Application

Upvotes: 1

Related Questions