DacServices.ExportBacpac Method (Stream, String, DacSchemaModelStorageType, IEnumerable<Tuple<String, String>>, Nullable<CancellationToken>)

Extracts schema and exports data from a database into a "bacpac" package.

Namespace:  Microsoft.SqlServer.Dac
Assembly:  Microsoft.SqlServer.Dac (in Microsoft.SqlServer.Dac.dll)

Syntax

'Declaration
Public Sub ExportBacpac ( _
    packageStream As Stream, _
    databaseName As String, _
    modelStorageType As DacSchemaModelStorageType, _
    tables As IEnumerable(Of Tuple(Of String, String)), _
    cancellationToken As Nullable(Of CancellationToken) _
)
'Usage
Dim instance As DacServices 
Dim packageStream As Stream 
Dim databaseName As String 
Dim modelStorageType As DacSchemaModelStorageType 
Dim tables As IEnumerable(Of Tuple(Of String, String))
Dim cancellationToken As Nullable(Of CancellationToken)

instance.ExportBacpac(packageStream, _
    databaseName, modelStorageType, _
    tables, cancellationToken)
public void ExportBacpac(
    Stream packageStream,
    string databaseName,
    DacSchemaModelStorageType modelStorageType,
    IEnumerable<Tuple<string, string>> tables,
    Nullable<CancellationToken> cancellationToken
)
public:
void ExportBacpac(
    Stream^ packageStream, 
    String^ databaseName, 
    DacSchemaModelStorageType modelStorageType, 
    IEnumerable<Tuple<String^, String^>^>^ tables, 
    Nullable<CancellationToken> cancellationToken
)
member ExportBacpac : 
        packageStream:Stream * 
        databaseName:string * 
        modelStorageType:DacSchemaModelStorageType * 
        tables:IEnumerable<Tuple<string, string>> * 
        cancellationToken:Nullable<CancellationToken> -> unit
public function ExportBacpac(
    packageStream : Stream, 
    databaseName : String, 
    modelStorageType : DacSchemaModelStorageType, 
    tables : IEnumerable<Tuple<String, String>>, 
    cancellationToken : Nullable<CancellationToken>
)

Parameters

  • packageStream
    Type: Stream
    The Stream to which to write the package.
  • databaseName
    Type: String
    The name of the source database.
  • tables
    Type: IEnumerable<Tuple<String, String>>
    The optional enumerable used to retrieve enumerator over set of tables for which data should be exported. For each Tuple in the enumeration the first item specifies the schema of the table, and the second specifies the base identifier of the table. If the value for this parameter is a null reference, data for all tables will be exported.
  • cancellationToken
    Type: Nullable<CancellationToken>
    The optional CancellationToken that can be used to indicate that the operation should be cancelled. Use of this object does not guarantee that the operation will be cancelled.

Exceptions

Exception Condition
ArgumentException

If the value for any of the required parameters is a null reference or an empty string.

DacServicesException

If an error occurs during schema deployment and data export; or if tables specifies a table that does not exist in the schema contained in the supplied package; or the supplied stream is not suitable for writing the package.

OperationCanceledException

If the CancellationToken has a cancellation requested and the operation could be cancelled.

See Also

Reference

DacServices Class

ExportBacpac Overload

Microsoft.SqlServer.Dac Namespace