locked
Restore Production Database Locally RRS feed

  • Question

  • I deployed a LS application about 3 months ago and now need to make some enhancements/bug fixes. I would like to restore a copy of the production database locally and use it to develop and debug the app without publishing it.

    I've already spent 4 hours trying to figure it out and am at my wits end. How do I do this?

    Thanks

    Jay


    Jay Turpin

    Tuesday, October 29, 2013 6:12 PM

Answers

  • Hi,

    - close your solution

    -  restore the database and then detach it.

    - Then go to the SQL Server DATA map en copy the 2 files xxx.mdf en xxx_log.ldf to your lightswitch folder: Bin/DATA

    - Change the security of both so Users has full Control (right click. Properties>Security tab)

    - rar your applicationDatabase.mdf and your log 

    - delete the applicationDatabase.mdf and your log 

    - rename the xxx files to ApplicationDatabase

    - rebuild your app and you get production data in your debug app.

    It's best that the schema of the production DB is the same as the intrinicDatabase.

    • Proposed as answer by LaurentzT Wednesday, October 30, 2013 1:12 PM
    • Marked as answer by Angie Xu Wednesday, November 6, 2013 2:31 AM
    Wednesday, October 30, 2013 1:06 PM

All replies

  • Hi Jay,

    I have some articles regarding debugging: http://blog.pragmaswitch.com/?tag=debug

    especially, this one can be useful for you:

    http://blog.pragmaswitch.com/?p=1342


    paul van bladel

    Tuesday, October 29, 2013 6:57 PM
  • Thanks for the response Paul. While your solutions get the job done, they are more complicated than we should have to go through. I can't pass this application off to a support team if they can't easily debug against a copy of the production-like data/

    I've been doing ASP.Net development for years and it's always been really easy to point to a different database/server to debug production issues. With LS, it is difficult, to say the least.

    LS Team - any solutions???


    Jay Turpin

    Tuesday, October 29, 2013 11:40 PM
  • Hi Jay,

    If you are trying to point a currently deployed application to a different database instance, you can open the web.config and update the connection string to your production-like DB instance. Is this what you are looking for?

    -Pierson

    Wednesday, October 30, 2013 2:22 AM
    Moderator
  • Thanks for the reply Pierson, but I am looking for an easy way to have the development environment use another database, either by easily restoring a backup to the local SQL Express database OR by changing the connection string of the _IntrinicDatabase.

    I'd like it to be easy enough that another developer on my team can pull the project down from source control, compile the app, run a script to refresh the local database and press F5 to start debugging.


    Jay Turpin

    Wednesday, October 30, 2013 12:26 PM
  • Hi,

    - close your solution

    -  restore the database and then detach it.

    - Then go to the SQL Server DATA map en copy the 2 files xxx.mdf en xxx_log.ldf to your lightswitch folder: Bin/DATA

    - Change the security of both so Users has full Control (right click. Properties>Security tab)

    - rar your applicationDatabase.mdf and your log 

    - delete the applicationDatabase.mdf and your log 

    - rename the xxx files to ApplicationDatabase

    - rebuild your app and you get production data in your debug app.

    It's best that the schema of the production DB is the same as the intrinicDatabase.

    • Proposed as answer by LaurentzT Wednesday, October 30, 2013 1:12 PM
    • Marked as answer by Angie Xu Wednesday, November 6, 2013 2:31 AM
    Wednesday, October 30, 2013 1:06 PM
  • Thanks Laurentz - I'll give that a try too.


    Jay Turpin

    Wednesday, October 30, 2013 2:46 PM