Sync-NAVTenantDatabase
The shared schema feature is for use in conjunction only with Microsoft hosted offerings in Dynamics 365, is unsupported in Dynamics NAV, and may not be used outside Dynamics 365.
Syntax
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 Dynamics NAV 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 DynamicsNAV -Id 'Test_Database@LOCALHOST'
This example synchronizes a tenants database with the id 'Test_Database@LOCALHOST', which has been mounted on the specified Dynamics NAV Server instance.
---------- EXAMPLE 2 ----------
Sync-NAVTenantDatabase -ServerInstance DynamicsNAV -Id 'Test_Database@LOCALHOST' -Mode CheckOnly
Dynamics NAV 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.
Type: | SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Confirm
Prompts you for confirmation before running the cmdlet.
Type: | SwitchParameter |
Aliases: | cf |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Force
Forces the command to run without asking for user confirmation.
Type: | SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-Id
Specifies the ID of a specific tenant database that you want to synchronize, such as Tenant1.
Type: | TenantDatabaseId |
Position: | 1 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | 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 Microsoft Dynamics NAV Server instance. CheckOnly or 3 Microsoft Dynamics NAV 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
Type: | SyncMode |
Accepted values: | ForceSync, Sync, CheckOnly |
Position: | Named |
Default value: | Sync |
Required: | False |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-ServerInstance
Specifies the name of a Dynamics NAV Server instance, for example, DynamicsNAV or myinstance. You can specify either the full name of an instance, such as MicrosoftDynamicsNavServer$myinstance or the short name such as myinstance.
Type: | String |
Position: | 0 |
Default value: | None |
Required: | True |
Accept pipeline input: | True |
Accept wildcard characters: | False |
-SharedSchema
Initializes an empty database with shared schema tables.
Type: | SwitchParameter |
Position: | Named |
Default value: | False |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
-WhatIf
Shows what would happen if the cmdlet runs. The cmdlet is not run.
Type: | SwitchParameter |
Aliases: | wi |
Position: | Named |
Default value: | None |
Required: | False |
Accept pipeline input: | False |
Accept wildcard characters: | False |
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 Microsoft Dynamics NAV Server instance. CheckOnly or 3 Microsoft Dynamics NAV 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