Export (0) Print
Expand All

SqlSyncScopeProvisioning Class

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

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

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

type SqlSyncScopeProvisioning =  class end

The SqlSyncScopeProvisioning type exposes the following members.

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

  NameDescription
Public propertyCommandTimeoutGets or sets the wait time, in seconds, before a provisioning command is stopped and an error is generated.
Public propertyObjectPrefixGets or sets the optional prefix that is used to identify objects that Sync Framework creates.
Public propertyObjectSchemaGets or sets the database schema in which Sync Framework creates objects.
Public propertyScopeNameGets the name of the scope or template that this object represents.
Public propertyTablesGets a collection of objects that each represent the provisioning of a database table.
Public propertyUserCommentGets or sets the user-specified comment about the scope.
Top

  NameDescription
Public methodApply()Applies the provisioning script to a SQL Server database by using the connection that was specified in the constructor.
Public methodApply(SqlConnection) Obsolete. Applies the provisioning script to a SQL Server database over the specified connection.
Public methodEquals (Inherited from Object.)
Protected methodFinalize (Inherited from Object.)
Public methodGetHashCode (Inherited from Object.)
Public methodGetType (Inherited from Object.)
Protected methodMemberwiseClone (Inherited from Object.)
Public methodPopulateFromScopeDescriptionSets the scope description from which the database should be provisioned.
Public methodPopulateFromTemplateSets the template-based scope description from which the database should be provisioned.
Public methodScopeExists(String)Indicates whether the specified scope exists in the database by using the connection that was specified in the constructor.
Public methodScopeExists(String, SqlConnection) Obsolete. Returns whether the specified scope exists.
Public methodScript()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 methodScript(String) Obsolete. Generates a string that contains the SQL code to provision the database for a particular scope.
Public methodSetCreateProceduresDefaultSets whether to create a set of stored procedures that insert, update, and delete data and synchronization metadata. The default setting is CreateOrUseExisting.
Public methodSetCreateProceduresForAdditionalScopeDefaultSets 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 methodSetCreateTableDefaultSets 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 methodSetCreateTrackingTableDefaultSets whether to create tables that store change-tracking metadata. The default setting is CreateOrUseExisting.
Public methodSetCreateTriggersDefaultSets whether to create, on base tables, triggers that update tracking tables. The default setting is CreateOrUseExisting.
Public methodSetPopulateTrackingTableDefaultSets whether to insert metadata into change-tracking tables for rows that already exist in base tables. The default setting is CreateOrUseExisting.
Public methodSetUseBulkProceduresDefaultSets 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 methodTemplateExistsReturns whether the specified template exists in the database.
Public methodToString (Inherited from Object.)
Top

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())


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