The preview environment for Dynamics 365 Business Central 2021 release wave 2 (BC19) is available now. Learn more: https://yzhums.com/17638/
I will continue to test and share some new features that I hope will be helpful.
Whenever the table schema is changed in a destructive way in an extension, it can have a downstream impact for any depending extension and potentially block updates until the breaking changes have been fully resolved. Until now, the process for handling destructive changes has been to implement them, and then obsolete them in due time to allow a more seamless process.
There can, however, sometimes be a need for making breaking changes. This can occur, for example, in cases where there is no downstream impact of the change, if dependencies are under full control (for example, for per-tenant extensions), or to make changes that are forced by new, clashing object identities introduced upstream.
To help with these scenarios, we are introducing the ability to deploy per-tenant extensions (PTEs) with force schema sync mode, which will allow destructive changes to the table schema in the new extension version.
When deploying a new customer-specific (per-tenant) extension to Business Central online, either through the Extension Management page or the admin center, it will now be possible to force any destructive table schema changes and circumvent the usual error when such changes are detected. This will allow the removal of specific tables or fields from the database.
As you might know, The data synchronization between each publish is controlled by the
schemaUpdateMode setting, which is specified in the
launch.json file. This setting consists of three options; Synchronize, Recreate, and ForceSync.
The default value for
schemaUpdateMode is set to the Synchronize mode, which means that every time you publish an extension to the development server, the data you entered previously stays.
When you set the schema update mode to Recreate, all the tables and table extensions are recreated at every publish, which means that all the data in those tables are lost. This means that you will get empty records when you publish your extension.
ForceSync is similar to the existing Synchronize schema update mode, but contains more freedom to make schema changes while retaining data. Data will be preserved in almost all cases with the exception of changing the main table’s primary key, in which case the data from the extension tables will be lost. Field renames are allowed and supported in this mode, but the data can only be preserved if you maintain the same ID for the field. If you change both the name and the ID of the field then the data will be lost.
In BC18 and previous versions, this schema update mode is only meant for testing and development and should never be used in production. This may result in a lot of redundant data in the production environment (ObsoleteState = Romoved).
But from BC19, this will change. When you upload and deploy the extension on the Extension Management page, you can find a new field, Schema Sync Mode.
So you can use ForceSync mode in a production environment now.
Schema Sync Mode
Specifies how to update the database schema for the extension. The Add option will warn you if the schemas are incompatible and will not apply the change. Force Sync will overwrite the current schema with the new version without warning. Force Sync can lead to data loss.
This operation means you will lose any data that is stored in the removed tables and fields. You will still have the option to restore the database. Thus, before a force sync in a production environment, this should be thoroughly tested in a matching sandbox environment, container, or on-premises installation.
Update info from Microsoft 2021/11/10:
Hope this will help.
Thanks for reading.