Dynamics 365 Business Central: PTE + SyncMode problem and troubleshooting

I think that you know that Dynamics 365 Business Central 2021 Wave 2 (version 19) introduced the possibility to do a forcing of the schema syncronization mode directly from the Extension Management page when uploading a new per-tenant extension. With this new option, it’s now possible to force any destructive table schema changes and circumvent the usual error when such changes are detected.

But there’s a problem 🙂

To directly explain the problem, I have created an extension that defines the following table:

This extension is on version 1.0.0.2 and it’s deployed as a per-tenant extension (PTE scope) on my SaaS sandbox environment. All good.

Now imagine that I want to remove the Active field from the above table, because on reviewing my code design I decide that it’s not needed (I’m in a development stage now, so I can do that).

For doing that, I create a new 1.0.0.3 version of my extension where I remove the Active field from the table definition (breaking change!) and I deploy the new PTE version on my online sandbox as follows, because I’m distracted:

This is the standard deployment way, where Schema Sync Mode is default setted as Add (so no breaking change admitted). What happens to my deployment? An epic fail, obviously:

The PTE deployment fails because a breaking change is detected (Active field is removed from the previous version).

Oh what a careless… I should use Schema Sync Mode = Force in order to do a breaking change. Let’s do that:

I select the same app file (version 1.0.0.3 previously failed) and now I redeploy it with force. Result? This:

Again, the deployment is failed for a breaking schema change, also with the Force schema setting! :O

This is not what I was expecting…

In this case, my Schema Sync Mode = Force is ignored and the system is using the Add option again (so, no breaking changes possible).

In general, please remember that Microsoft is working on a “fix” for this strange behaviour. If you are in this situation, what you should always do is to create a new extension version (also if the previous upload with Schema Sync Mode = Add is failed) and then do the force sync with this new app version.

In the above example, just create a new 1.0.0.4 version of the app (with the Active field removed) and then upload it with Schema Sync Mode = Force:

Result:

The app is now successfully updated and the Active field is removed from the table.

Hoping this will help you on avoiding headaches on trying to understand WHY this noise… 😉

2 Comments

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.