Preventing Data Loss When Publishing Apps in Business Central Cloud

ron ronnie 0 Reputation points
2025-09-01T12:23:28.3866667+00:00

Using Microsoft 365 Business Central Cloud, there have been instances where publishing a new app directly to the environment leads to the loss of data, specifically employee information and cues. The recreate option is not being utilized. What steps can be taken to publish the app without losing existing data?

Microsoft 365 and Office | Development | Microsoft 365 App Publishing
{count} votes

1 answer

Sort by: Most helpful
  1. TiNo-T 9,285 Reputation points Microsoft External Staff Moderator
    2025-09-01T14:35:09.37+00:00

    Dear @ron ronnie

    Thank you so much for contacting Microsoft Q&A Forum. 

    Based on your description, I can see that your concern about data loss when publishing a new app in Microsoft Dynamics 365 Business Central Cloud is valid and typically stems from how the schemaUpdateMode is configured during app deployment. Also, you mentioned that you are not using the Recreate option intentionally, but still experiencing data loss, it’s likely that the schemaUpdateMode is accidentally set to "Recreate" in their launch.json or during PowerShell publishing. 

    I have researched and found several ideas that you can try or consult to see if they can help: 

    To safely publish an app without losing existing data: 

    1.Use the Synchronize mode and avoid using "Recreate" unless explicitly needed in dev environments: 

    • Ensure the launch.json file contains: 
    "schemaUpdateMode": "Synchronize"
    

     This retains all existing data during publishing.  

    • If it is in Recreate mode: deletes all data in tables and extensions every time the app is published. 

    Reference: Synchronizing extension test data - Business Central | Microsoft Learn 

    2.Avoid breaking schema changes: 

    If schema changes are needed: 

    • Use upgrade codeunits to migrate data safely. 
    • Avoid changing primary keys or deleting fields directly. 

    You can consult in this link: Debug upgrade and install code - Business Central | Microsoft Learn 

    3.Use PowerShell for controlled publishing:  Use the following commands via Business Central Administration Shell, you can try this to see if it works: 

    Publish-NAVApp -ServerInstance YourServer -Path ".\YourApp.app" 
    Sync-NAVApp -ServerInstance YourServer -Name "YourApp" -Version "1.0.0.0" -Tenant "default" 
    Install-NAVApp -ServerInstance YourServer -Name "YourApp" -Tenant "default"
    

    This method gives more control and avoids unintended schema resets. Reference: Publishing and Installing an Extension - Business Central | Microsoft Learn 

    Additional notes: you should have a backup data before major changes. Reference: Restoring an environment in the admin center - Business Central | Microsoft Learn 

    I hope this information can help you in this case and please kindly correct me if I misunderstand your concern. 

    Wish you a pleasant day!


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment". 

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    User's image


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.