Share via


Sync-NAVTenantDatabase

DO NOT USE: This cmdlet is for internal use only. It can't be used for Business Central on-premises tenants. For information about managing on-premises tenants, see https://go.microsoft.com/fwlink/?linkid=2153727.

Syntax

Default (Default)

Sync-NAVTenantDatabase
    [-Id] <TenantDatabaseId>
    [-Mode <SyncMode>]
    [-CommitPerTable]
    [-SharedSchema]
    [-ServerInstance] <String>
    [-Force]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

Description

Use the Sync-NAVTenantDatabase cmdlet to synchronize the database schema in a tenant database with the schema in the application database. Also, the Business Central Server instance must be configured for multitenancy. The application database contains tables that define the application. The tenant database must contain the SQL Server tables that the application requires.

Examples

EXAMPLE 1

Sync-NAVTenantDatabase -ServerInstance BC -Id 'Test_Database@LOCALHOST'

This example synchronizes a tenants database with the id 'Test_Database@LOCALHOST', which has been mounted on the specified Business Central Server instance.

EXAMPLE 2

Sync-NAVTenantDatabase -ServerInstance BC -Id 'Test_Database@LOCALHOST' -Mode CheckOnly

Business Central Server tests whether schema changes in the connected application database will result in data loss in the tenant database if the changes are applied.

Parameters

-CommitPerTable

Specifies that database schema modifications are committed by separate transactions on each affected table. Transactions are run one at a time, as they occur. With the default behavior (that is, without using the -CommitPerTable parameter), all modifications are committed in a single transaction. Using this method provides better protection against leaving the database in an inconsistent state than using the -CommitPerTable parameter. If the synchronization process is terminated before it is completed, any changes that were made before the problem occurred are rolled back, returning the database to its original state. The drawback is that for large databases, the synchronization process can take a long time and consume considerable computer resources. The advantage of setting the -CommitPerTable is that it will decrease the time that is required to complete the synchronization process and consume less computer resources, which can be useful for large databases when performance is a concern. However, when you set this parameter, committed changes are not rolled back if the synchronization process is terminated before it is completed. This can result in a partial synchronization of the database, which might leave the database inoperable. We recommend that you make a backup of the database before you run the Sync-NAVTenant cmdlet. Also, tables are not always locked during synchronization. Therefore, you should prohibit users from connecting to the database during synchronization.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Confirm

Prompts you for confirmation before running the cmdlet.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:cf

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Force

Forces the command to run without asking for user confirmation.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-Id

Specifies the ID of a specific tenant database that you want to synchronize, such as Tenant1.

Parameter properties

Type:TenantDatabaseId
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:1
Mandatory:True
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-Mode

Specifies how the database schema for the tenant database is synchronized with the database schema that the mounted application database defines. The default value is Sync. You can specify the parameter value by name or by integer as follows: ForceSync or 0 The database schema in the tenant database is updated with the application database schema even if data is lost. For example, if a table or a field has been deleted in the current application, the table or field is removed from the tenant database even if it contains data. Sync or 2 The database schema in the tenant database will be updated unless data is lost. For example, if a table or a field has been deleted in the current application, and it contains data in the tenant database, the tenant cannot be mounted against the Business Central Server instance. CheckOnly or 3 Business Central Server tests if a change in the current application will result in data loss in the tenant database if the tenant is mounted with Mode set to ForceSync. For example, if a table or a field has been deleted in the current application and it contains data in the tenant database.

Possible values: ForceSync, Sync, CheckOnly

Parameter properties

Type:SyncMode
Default value:Sync
Accepted values:ForceSync, Sync, CheckOnly
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:True
Value from remaining arguments:False

-ServerInstance

Specifies the name of a Business Central Server instance, for example, BC or myinstance. You can specify either the full name of an instance, such as MicrosoftDynamicsNavServer$myinstance or the short name such as myinstance.

Parameter properties

Type:String
Default value:None
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:0
Mandatory:True
Value from pipeline:True
Value from pipeline by property name:True
Value from remaining arguments:False

-SharedSchema

Initializes an empty database with shared schema tables.

Parameter properties

Type:SwitchParameter
Default value:False
Supports wildcards:False
DontShow:False

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

Parameter properties

Type:SwitchParameter
Default value:None
Supports wildcards:False
DontShow:False
Aliases:wi

Parameter sets

(All)
Position:Named
Mandatory:False
Value from pipeline:False
Value from pipeline by property name:False
Value from remaining arguments:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

Inputs

Microsoft.Dynamics.Nav.Types.TenantDatabaseId

By property name: Id

Microsoft.Dynamics.Nav.Types.SyncMode

Specifies how the database schema for the tenant database is synchronized with the database schema that the mounted application database defines. The default value is Sync. You can specify the parameter value by name or by integer as follows: ForceSync or 0 The database schema in the tenant database is updated with the application database schema even if data is lost. For example, if a table or a field has been deleted in the current application, the table or field is removed from the tenant database even if it contains data. Sync or 2 The database schema in the tenant database will be updated unless data is lost. For example, if a table or a field has been deleted in the current application, and it contains data in the tenant database, the tenant cannot be mounted against the Business Central Server instance. CheckOnly or 3 Business Central Server tests if a change in the current application will result in data loss in the tenant database if the tenant is mounted with Mode set to ForceSync. For example, if a table or a field has been deleted in the current application and it contains data in the tenant database.

System.String

ServerInstance