Share via


SqlSyncScopeProvisioning Class

Represents the provisioning of a SQL Server database for a particular scope that is represented by a DbSyncScopeDescription object.

Inheritance Hierarchy

System.Object
  Microsoft.Synchronization.Data.SqlServer.SqlSyncScopeProvisioning

Namespace:  Microsoft.Synchronization.Data.SqlServer
Assembly:  Microsoft.Synchronization.Data.SqlServer (in Microsoft.Synchronization.Data.SqlServer.dll)

Syntax

'Declaration
Public Class SqlSyncScopeProvisioning
'Usage
Dim instance As SqlSyncScopeProvisioning
public class SqlSyncScopeProvisioning
public ref class SqlSyncScopeProvisioning
type SqlSyncScopeProvisioning =  class end
public class SqlSyncScopeProvisioning

The SqlSyncScopeProvisioning type exposes the following members.

Constructors

  Name Description
Public method SqlSyncScopeProvisioning() Obsolete. Initializes a new instance of the SqlSyncScopeProvisioning class by using default values.
Public method SqlSyncScopeProvisioning(SqlConnection) Initializes a new instance of the SqlSyncScopeProvisioning class with the specified connection.
Public method SqlSyncScopeProvisioning(DbSyncScopeDescription) Obsolete. Initializes a new instance of the SqlSyncScopeProvisioning class for the specified scope.
Public method SqlSyncScopeProvisioning(SqlConnection, DbSyncScopeDescription) Initializes a new instance of the SqlSyncScopeProvisioning class with the specified connection and scope description.
Public method SqlSyncScopeProvisioning(SqlConnection, SqlSyncScopeProvisioningType) Initializes a new instance of the SqlSyncScopeProvisioning class with the specified connection and provisioning type
Public method SqlSyncScopeProvisioning(SqlConnection, DbSyncScopeDescription, SqlSyncScopeProvisioningType) Initializes a new instance of the SqlSyncScopeProvisioning class with the specified connection, scope description, and provisioning type.

Top

Properties

  Name Description
Public property CommandTimeout Gets or sets the wait time, in seconds, before a provisioning command is stopped and an error is generated.
Public property ObjectPrefix Gets or sets the optional prefix that is used to identify objects that Sync Framework creates.
Public property ObjectSchema Gets or sets the database schema in which Sync Framework creates objects.
Public property ScopeName Gets the name of the scope or template that this object represents.
Public property Tables Gets a collection of objects that each represent the provisioning of a database table.
Public property UserComment Gets or sets the user-specified comment about the scope.

Top

Methods

  Name Description
Public method Apply() Applies the provisioning script to a SQL Server database by using the connection that was specified in the constructor.
Public method Apply(SqlConnection) Obsolete. Applies the provisioning script to a SQL Server database over the specified connection.
Public method Equals (Inherited from Object.)
Protected method Finalize (Inherited from Object.)
Public method GetHashCode (Inherited from Object.)
Public method GetType (Inherited from Object.)
Protected method MemberwiseClone (Inherited from Object.)
Public method PopulateFromScopeDescription Sets the scope description from which the database should be provisioned.
Public method PopulateFromTemplate Sets the template-based scope description from which the database should be provisioned.
Public method ScopeExists(String) Indicates whether the specified scope exists in the database by using the connection that was specified in the constructor.
Public method ScopeExists(String, SqlConnection) Obsolete. Returns whether the specified scope exists.
Public method Script() Generates a string that contains the SQL code to provision the database for a particular scope by using the connection that was specified in the constructor.
Public method Script(String) Obsolete. Generates a string that contains the SQL code to provision the database for a particular scope.
Public method SetCreateProceduresDefault Sets whether to create a set of stored procedures that insert, update, and delete data and synchronization metadata. The default setting is CreateOrUseExisting.
Public method SetCreateProceduresForAdditionalScopeDefault Sets whether to create additional stored procedures for a scope that contains tables that have already been provisioned for other scopes. For example, this scope adds a filter column to a table that has already been provisioned without the filter column. Set this option to Create to ensure that an additional change enumeration procedure is created that can handle the filter column. The default setting is Skip.
Public method SetCreateTableDefault Sets whether to create base tables when a scope is configured. Base tables are tables that contain user data, as opposed to tracking tables that contain synchronization metadata. The default setting is CreateOrUseExisting.
Public method SetCreateTrackingTableDefault Sets whether to create tables that store change-tracking metadata. The default setting is CreateOrUseExisting.
Public method SetCreateTriggersDefault Sets whether to create, on base tables, triggers that update tracking tables. The default setting is CreateOrUseExisting.
Public method SetPopulateTrackingTableDefault Sets whether to insert metadata into change-tracking tables for rows that already exist in base tables. The default setting is CreateOrUseExisting.
Public method SetUseBulkProceduresDefault Sets a value that indicates whether bulk procedures should be created when provisioning stored procedures. The default setting is true when provisioning a SQL Server 2008 or SQL Azure database; otherwise, it is false.
Public method TemplateExists Returns whether the specified template exists in the database.
Public method ToString (Inherited from Object.)

Top

Examples

The following code example creates a provisioning object for the filtered_customer scope, specifies that base tables should not be created in the server database, and specifies that all synchronization-related objects should be created in a database schema named "Sync". As part of provisioning the scope, the code defines a filter on the Customer table. Only rows that match that filter will be synchronized. No filter is defined on the CustomerContact table; therefore all rows from that table will be synchronized. After provisioning options are defined, the Apply method is called to create the change-tracking infrastructure in the server database; and the provisioning script is written to a file. To view this code in the context of a complete example, see How To: Execute Database Synchronization (SQL Server).

SqlSyncScopeProvisioning serverConfig = new SqlSyncScopeProvisioning(serverConn, scopeDesc);
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip);
serverConfig.ObjectSchema = "Sync";

// Specify which column(s) in the Customer table to use for filtering data, 
// and the filtering clause to use against the tracking table.
// "[side]" is an alias for the tracking table.
serverConfig.Tables["Sales.Customer"].AddFilterColumn("CustomerType");
serverConfig.Tables["Sales.Customer"].FilterClause = "[side].[CustomerType] = 'Retail'";

// Configure the scope and change-tracking infrastructure.
serverConfig.Apply();

// Write the configuration script to a file. You can modify 
// this script if necessary and run it against the server
// to customize behavior.
File.WriteAllText("SampleConfigScript.txt",
    serverConfig.Script());
Dim serverConfig As New SqlSyncScopeProvisioning(serverConn, scopeDesc)
serverConfig.SetCreateTableDefault(DbSyncCreationOption.Skip)
serverConfig.ObjectSchema = "Sync"

' Specify which column(s) in the Customer table to use for filtering data, 
' and the filtering clause to use against the tracking table. 
' "[side]" is an alias for the tracking table. 
serverConfig.Tables("Sales.Customer").AddFilterColumn("CustomerType")
serverConfig.Tables("Sales.Customer").FilterClause = "[side].[CustomerType] = 'Retail'"

' Configure the scope and change-tracking infrastructure. 
serverConfig.Apply()

' Write the configuration script to a file. You can modify 
' this script if necessary and run it against the server 
' to customize behavior. 
File.WriteAllText("SampleConfigScript.txt", serverConfig.Script())

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

Microsoft.Synchronization.Data.SqlServer Namespace