locked
Local or Intrinsic Database default initial values RRS feed

  • Question

  • Can anyone explain to me about the local intrinsic database in Visual Studio 2012 Lightswitch? Is the whole point of this database for testing and is not copied to the 'release' build when published? During development I defined the different tables, their properties and relationships. Is this information used to create a database or copied into an empty database that I link?

    My first problem is that I am trying to create a lookup table for countries and states in the USA. I created a table for each and I need to load up the table with the information (Where to get the information without doing it manually is a different problem).

    The other question comes from the "publishing" process where I am asked for a database "connection string" and I'm not entirely sure what that means or where to get it. I was under the impression Lightswitch created a local database for my desktop application modeled off of the intrinsic database I defined.

    I know that was a lot of questions, but any help would be greatly appreciated.

    Thanks for your time!

    Sunday, December 23, 2012 7:27 PM

Answers

  • Yes, you're right, the intrinsic database is for testing, & the records don't get copied to the deployed database. Initialising data is a pretty common requirement, but one that doesn't have an out-of-the-box solution yet.

    To create a series of default values in the published application's database you can:

    • Use SQL scripts to initialise the data
    • Programmatically add records to the tables, if you detect that tables are empty
    • Use a data compare tool (either built-into VS Premium or above, or a 3rd-paty tool)
    • Create a screen for each lookup table (or one screen for all of them), then import the data from txt/csv files, or manually enter the data

    When you publish a LightSwitch application, you need to point to an installed instance of SQL Server (2005 or above). The Deploy Wizard will in fact create the database & tables for you, but you have to tell it where. If you're publishing to your local machine, you can install/use the instance of SQL Server Express (or use any other instance if you have one installed on the machine already).

    I hope that helps at least a little.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Angie Xu Monday, December 31, 2012 6:56 AM
    Wednesday, December 26, 2012 6:17 AM
    Moderator

All replies

  • Yes, you're right, the intrinsic database is for testing, & the records don't get copied to the deployed database. Initialising data is a pretty common requirement, but one that doesn't have an out-of-the-box solution yet.

    To create a series of default values in the published application's database you can:

    • Use SQL scripts to initialise the data
    • Programmatically add records to the tables, if you detect that tables are empty
    • Use a data compare tool (either built-into VS Premium or above, or a 3rd-paty tool)
    • Create a screen for each lookup table (or one screen for all of them), then import the data from txt/csv files, or manually enter the data

    When you publish a LightSwitch application, you need to point to an installed instance of SQL Server (2005 or above). The Deploy Wizard will in fact create the database & tables for you, but you have to tell it where. If you're publishing to your local machine, you can install/use the instance of SQL Server Express (or use any other instance if you have one installed on the machine already).

    I hope that helps at least a little.


    Yann - LightSwitch Central - Click here for FREE Themes, Controls, Types and Commands
     
    Please click "Mark as Answer" if a reply answers your question. Please click "Vote as Helpful" , if you find a reply helpful.
     
    By doing this you'll help others to find answers faster.

    • Marked as answer by Angie Xu Monday, December 31, 2012 6:56 AM
    Wednesday, December 26, 2012 6:17 AM
    Moderator
  • Hi dmor

    I will mark Yann's reply as answer, if the marked answer is not helpful to solve your problem, please unmark and give quick response.

    Kind regards


    Angie xu
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Monday, December 31, 2012 6:56 AM
  • Hi Yann,

    you write that the records do not get copied to the deployed database.

    But is it possible to deploy the intrinsic application database for desktop and/or web to use when the application is running.

    I am using the intrinsic database and an external database. And I would like to keep it that way. But when I deploy the application, all my tables are copied to the external database.

    Friday, August 29, 2014 8:05 AM
  • In order to get your data from the intrinsic database to your published database, you can use:

    1) In Visual Studio 2013, you can go to Tools --> SQL Server --> New Data Comparison

    This will let you selectively copy data from the intrinsic database to your published database.

    2) SQL Database Migration Wizard )from codeplex.com- This will transfer data between SQL databases and SQL Azure databases.  I have found that this works better for large amounts of data.

    SQL Database Migration Wizard

    Regarding the connection string, if you enter a database name that does not exist, the publishing process will create a new, empty database; if you enter an existing name, it will try to update the schema if it's different.  Be careful not to manually change the structure of the database directly; do it in the LightSwitch designer or you will get an error when you try to publish again.

    If you don't have any database changes when you publish, uncheck the option to publish the schema in the publish wizard.

    Note that if you add indexes to your database, when you publish the schema after that, the indexes will be deleted.  I created a script to create my indexes that I run after publishing to get the indexes back.

    Mark

    Friday, August 29, 2014 4:43 PM