none
How to Publish a windows application with the new LocalDB? RRS feed

  • Question

  • I have been building windows applications with embedded MDF files for a while now.  In the past I would force the client to download and install SQL Server Express in order to run the application.  This is just a simple as adding SQL Server Express 2005 or 2008 as part of the prerequisite in the ClickOnce Publication.  Now with the New LocalDB Microsoft claims to have a lightweight tool that can run without forcing clients to do a 10 minute download of SQL Server Express when applications require local databases instead of web based, or network databases.

    I built an application that works on my development computer, but granted I have SQL Server, but when I try to install and run it on other machines it says that I am missing SQL Server Express and the app fails to run because of this.  I was under the impression that this new LocalDB could be installed without requiring clients to install SQL Server Express.  I think the issue lies in the prerequisites or something. Under Publish > Prerequisites I have checked SQL Server Express Local DB, but when I install it on another machine it never installs this.  Instead it just gives me an error message referring to missing a SQL Server Express.  It seems like SQL Server Express is required on the client side into order to run applications that use local DB.  Is this really the case?

    So at this point my question  is basically this:

     Is it possible to publish an application with an embedded MDF that uses LocalDB but does not force the clients to install SQL Server Express as the prerequisite using ClickOnce Publish option in Visual Studio 2012?  If so, what are the prerequisites that must be used in the publishing? 

    • Moved by Amanda Zhu Friday, July 26, 2013 9:54 AM move to a more appropriate forum
    Wednesday, July 24, 2013 8:04 PM

All replies

  • Hi Ian Guthrie,

    Actually I would recommend you read this thread:

    http://stackoverflow.com/questions/6195733/deploying-a-database-and-application-with-clickonce

    "

    You have a couple of options. First, if this is a simple database I recommend that you forego using SQL Express and use SQL Server Compact. A Compact SQL database is a file that can be bundled with your application installation. Below is a link guiding you through the creation process of a SQL Compact database.

    http://technet.microsoft.com/en-us/library/ms173009.aspx

    The following link discusses setting up the necessary dependencies and prerequisites for SQL Server Compact. (Note, you will need to scroll to the section entitled Private File–Based Deployment.)

    http://msdn.microsoft.com/en-us/library/aa983326(v=VS.100).aspx

    If you have a complex database, or one that may grow larger than the 3GB limit that is set for SQL Compact databases, the only alternative is to set SQL Server Express as a prerequisite to your application and once it is installed create a routine within your application that checks to see if your database exists in SQL Express and, if not, launches a database creation and updating routine.

    In my case, I have a heavy, data-driven application that was written before SQL Compact was out and had to function in environments that were often disconnected from our servers. I had to use SQL Express so that we had to develop a mechanism to check for database updates when the server was available. If there are updates, encrypted script files are downloaded and executed, sequentially against the child database. After the database container is updated, a follow-up routine is called to check and synchronize the data.

    --EDIT--

    I wanted to quickly respond that, yes, you can bundle and attach a SQL Server database programatically to a local instance of SQL Server. There are many barriers to this and if you have a user base that uses multiple versions of Windows, PC architectures and multiple different security scenarios, you will probably have trouble consistently attaching your database to the user's SQL Server. Yes, it can be done. However, I'd recommend avoiding that scenario at all possibly costs.

    "Comments from RLH sounds helpful to you. But if you want to include any database file, you may refer to the following pages:

    http://msdn.microsoft.com/en-us/library/6fehc36e.aspx

    http://msdn.microsoft.com/en-us/library/vstudio/aa983326.aspx

    Regards,


    Barry Wang
    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.

    Friday, July 26, 2013 9:58 AM
    Moderator
    • As I mentioned I am very familiar with setting SQL Server Express as a prerequisite and getting the client to download this.  I am familiar with how to do this with compact as well.  But what I am trying to do is use the new LocalDB and not SQL server express, or compact.  My question is around how to set LocalDB as a prerequisite in the installation package using ClickOnce  (Not SQL Express or Compact).  There is virtually no documentation / support for using LocalDB this way.  So back to my original question:  Is it possible to publish an application with an embedded MDF that uses LocalDB but does not force the clients to install SQL Server Express as the prerequisite using ClickOnce Publish option in Visual Studio 2012?  If so, what are the prerequisites that must be used in the publishing? 
    Monday, July 29, 2013 12:34 PM
  • Hi lan Guthrie,

    Sorry for haven't addressed your issue.

    Yes you can include SqlLocalDB.msi which is about 33MB as your prerequisite component in clickonce. Please have a look at this thread:

    http://social.msdn.microsoft.com/Forums/windows/en-US/21cc111b-6d39-46e7-8c50-fd1554529b7d/how-to-include-localdb-in-clickonce-prereq-list

    Check the following:

    "There's no a LocalDB bootstrapper published, so you will need to make it yourself and add it to your installer as a prerequisite component.

    You can ref my this post: http://social.msdn.microsoft.com/Forums/en/winformssetup/thread/518b0648-9d6e-4d7b-8972-80a9c16d7b20 

    http://msdn.microsoft.com/en-us/library/ms165429.aspx or make it manually. You also can ref the ready-made ones(such as this: C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Bootstrapper\Packages\DotNetFX40) to manual generate yours."

    For the LocalDB msi file, you can download it here: 

    http://www.microsoft.com/en-in/download/details.aspx?id=29062

    Just choose download you'll be able to download that 33MB file.

    Regards,


    Barry Wang
    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, August 5, 2013 8:05 AM
    Moderator
  • Thanks for the feedback.  I would like to submit that the lack of automatic Clickonce support is a major design flaw in LocalDB.  Developers are looking for an easy way to deploy tools.  While the information you supplied points me to a solution I can use, it is quite cumbersome and this is going to be a major turn off to most developers looking for a quick point solution.  I strongly encourage Microsoft to consider adding an automated bootstrap to clickonce that encompasses everything we need to deploy LocalDB.  Without this, most developers will be likely just stick with SQL Server Express and force their clients to do longer downloads. Please consider my feedback and provide us with a "hotfix" or a windows update in the near future that addresses this serious concern.  I think this would be a great tool, but I like so many others will likely not spend 5 -10 hours trouble shooting, beating up message boards trying to learn how to hard code a boot strap install when clickonce does it automatically.  Thanks though, and let me know when an update is available.
    Tuesday, August 6, 2013 1:05 AM
  • Hello lan,

    Could you please send a feedback on this site about this issue:

    https://visualstudio.uservoice.com/forums/121579-visual-studio

    Visual Studio team will pay attention to this hot issue.

    Regards,


    Barry Wang
    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.

    Tuesday, August 6, 2013 1:27 AM
    Moderator