TSqlModel TSqlModel TSqlModel Class

Definition

Represents a model of a SQL Server database schema.

public sealed class TSqlModel : IDisposable
type TSqlModel = class
    interface IDisposable
Public NotInheritable Class TSqlModel
Implements IDisposable
Inheritance
TSqlModelTSqlModelTSqlModel
Implements

Constructors

TSqlModel(String) TSqlModel(String) TSqlModel(String)

Loads a model from a DacPackage or BacPackage.

This is equivalent to calling LoadFromDacpac(String, ModelLoadOptions) with default values.

TSqlModel(SqlServerVersion, TSqlModelOptions) TSqlModel(SqlServerVersion, TSqlModelOptions) TSqlModel(SqlServerVersion, TSqlModelOptions)

Creates an empty model that targets a specific SqlServerVersion

TSqlModel(String, DacSchemaModelStorageType) TSqlModel(String, DacSchemaModelStorageType) TSqlModel(String, DacSchemaModelStorageType)

Loads a model from a DacPackage or BacPackage.

This is equivalent to calling LoadFromDacpac(String, ModelLoadOptions) with default values for everything except the modelStorageType.

TSqlModel(String, DacSchemaModelStorageType, CancellationToken) TSqlModel(String, DacSchemaModelStorageType, CancellationToken) TSqlModel(String, DacSchemaModelStorageType, CancellationToken)

Loads a model from a DacPackage or BacPackage.

This is equivalent to calling LoadFromDacpac(String, ModelLoadOptions) with default values for everything except the modelStorageType.

Properties

CollationComparer CollationComparer CollationComparer

Comparer that can compare strings and ObjectIdentifiers using the collation of this TSqlModel. This can be very useful when comparing objects in the model since comparisons will be consistent with the expected comparison results in SQL Server

DisplayServices DisplayServices DisplayServices

Gets the DisplayServices that support producing display properties for objects in the model.

EngineVersion EngineVersion EngineVersion

The specific engine version targeted by the model.

For On Premises platforms this will be consistent with the SqlServerVersion - for instance Sql90 will have an engine version of 9.

For Microsoft Azure SQL Database the minimum valid version is 11, and the engine version will affect what features are supported in the model.

IsScriptBacked IsScriptBacked IsScriptBacked

Is this a model that is backed by scripts? In this case objects in the UserDefined scope will have source position information including a source name and information. This is important for scenarios such as use of the CodeAnalysisService.

Any empty TSqlModel created will be script-backed by default. Models loaded from a Dacpac will only be scipt backed if the LoadAsScriptBackedModel option is enabled. Note that creating a script-backed model will take longer than using a standard model loaded from a Dacpac

Version Version Version

The specific SQL Server release targeted by the model.

Methods

AddObjects(TSqlScript) AddObjects(TSqlScript) AddObjects(TSqlScript)

Adds objects to the model based on the contents of a TSqlScript object. The script should be valid TSql with no parse errors.

Objects added using this method cannot be updated or deleted at a later point as update/delete requires a script name to be specified when adding the objects. If this is a requirement use the AddOrUpdateObjects(TSqlScript, String, TSqlObjectOptions) method instead.

AddObjects(String) AddObjects(String) AddObjects(String)

Adds objects to the model based on the contents of a TSql Script string. The script should consist of valid TSql DDL statements.

Objects added using this method cannot be updated or deleted at a later point as update/delete requires a script name to be specified when adding the objects. If this is a requirement use the AddOrUpdateObjects(String, String, TSqlObjectOptions) method instead.

AddObjects(TSqlScript, TSqlObjectOptions) AddObjects(TSqlScript, TSqlObjectOptions) AddObjects(TSqlScript, TSqlObjectOptions)

Add Objects to the model based on the contents of a TSqlScript object, plus additional metadata defined by a TSqlObjectOptions object The script should be valid TSql with no parse errors.

Objects added using this method cannot be updated or deleted at a later point as update/delete requires a script name to be specified when adding the objects. If this is a requirement use the AddOrUpdateObjects(TSqlScript, String, TSqlObjectOptions) method instead.

AddObjects(String, TSqlObjectOptions) AddObjects(String, TSqlObjectOptions) AddObjects(String, TSqlObjectOptions)

Add Objects to the model based on the contents of a TSql Script string, plus additional metadata defined by a TSqlObjectOptions object The script should consist of valid TSql DDL statements.

Objects added using this method cannot be updated or deleted at a later point as update/delete requires a script name to be specified when adding the objects. If this is a requirement use the AddOrUpdateObjects(String, String, TSqlObjectOptions) method instead.

AddOrUpdateObjects(TSqlScript, String, TSqlObjectOptions) AddOrUpdateObjects(TSqlScript, String, TSqlObjectOptions) AddOrUpdateObjects(TSqlScript, String, TSqlObjectOptions)

Adds or updates the objects defined for a specified sourceName with the objects defined in the inputScript. If any objects were previously added with the same sourceName these will be completely replaced The object definitions are based on the contents of a TSqlScript object plus additional metadata defined by a TSqlObjectOptions object The script should consist of valid TSql DDL statements.

AddOrUpdateObjects(String, String, TSqlObjectOptions) AddOrUpdateObjects(String, String, TSqlObjectOptions) AddOrUpdateObjects(String, String, TSqlObjectOptions)

Adds or updates the objects defined for a specified sourceName with the objects defined in the inputScript. If any objects were previously added with the same sourceName these will be completely replaced The object definitions are based on the contents of a TSql Script string plus additional metadata defined by a TSqlObjectOptions object The script should consist of valid TSql DDL statements.

CheckVersionCompatibility(SqlServerVersion, CancellationToken) CheckVersionCompatibility(SqlServerVersion, CancellationToken) CheckVersionCompatibility(SqlServerVersion, CancellationToken)

Validates the model to determine whether it contains any elements that are not compatible with a target version of SQL Server or Azure SQL Database, and returns any errors or warnings.

ConvertToScriptedObject(TSqlObject, String) ConvertToScriptedObject(TSqlObject, String) ConvertToScriptedObject(TSqlObject, String)

Converts a specific top-level object in the model into a scripted representation of itself. This is useful when starting from a database sourced model and the caller wishes to modify this object's contents.

CopyModelOptions() CopyModelOptions() CopyModelOptions()

Copies the DatabaseOptions for the model to a TSqlModelOptions object. This is useful if you wish to duplicate the options for a model when creating a new model.

DeleteObjects(String) DeleteObjects(String) DeleteObjects(String)

Deletes any objects that were added to the model with the specified sourceName.

Dispose() Dispose() Dispose()

Releases all resources used by the TSqlModel object.

GetModelErrors() GetModelErrors() GetModelErrors()

Returns all DacModelErrors that are present in the model.

GetObject(ModelTypeClass, ObjectIdentifier, DacQueryScopes) GetObject(ModelTypeClass, ObjectIdentifier, DacQueryScopes) GetObject(ModelTypeClass, ObjectIdentifier, DacQueryScopes)

Returns TSqlObjects of the specified objectType and id. Only top level ModelTypeClass types are supported by this method - the objectType parameter must be in the types returned from the TopLevelTypes method or the call will fail.

GetObjects(DacQueryScopes, ModelTypeClass[]) GetObjects(DacQueryScopes, ModelTypeClass[]) GetObjects(DacQueryScopes, ModelTypeClass[])

Returns all TSqlObjects matching the list of typeFilters. Only top level ModelTypeClass types are supported by this method - all types in the typeFilters parameter must be present in the TopLevelTypes or the call will fail.

GetObjects(String, ModelTypeClass[]) GetObjects(String, ModelTypeClass[]) GetObjects(String, ModelTypeClass[])

Returns all TSqlObjects in a given sourceName document filtered by ModelTypeClasss specified by the typeFilters parameter.

GetObjects(ModelTypeClass, ObjectIdentifier, DacQueryScopes) GetObjects(ModelTypeClass, ObjectIdentifier, DacQueryScopes) GetObjects(ModelTypeClass, ObjectIdentifier, DacQueryScopes)

Returns all TSqlObjects that match the ModelTypeClass and ObjectIdentifier. Only top level ModelTypeClass types are supported by this method - the objectType parameter must be in the types returned from the TopLevelTypes method or the call will fail.

LoadFromDacpac(Stream, ModelLoadOptions) LoadFromDacpac(Stream, ModelLoadOptions) LoadFromDacpac(Stream, ModelLoadOptions)

Loads a model from a DacPackage or BacPackage using the specified options to configure what kind of storage to use, and whether to load a script-backed model or not.

LoadFromDacpac(String, ModelLoadOptions) LoadFromDacpac(String, ModelLoadOptions) LoadFromDacpac(String, ModelLoadOptions)

Loads a model from a DacPackage or BacPackage using the specified options to configure what kind of storage to use, and whether to load a script-backed model or not.

LoadFromDacpac(Stream, ModelLoadOptions, CancellationToken) LoadFromDacpac(Stream, ModelLoadOptions, CancellationToken) LoadFromDacpac(Stream, ModelLoadOptions, CancellationToken)

Loads a model from a DacPackage or BacPackage using the specified options to configure what kind of storage to use, and whether to load a script-backed model or not.

LoadFromDacpac(String, ModelLoadOptions, CancellationToken) LoadFromDacpac(String, ModelLoadOptions, CancellationToken) LoadFromDacpac(String, ModelLoadOptions, CancellationToken)

Loads a model from a DacPackage or BacPackage using the specified options to configure what kind of storage to use, and whether to load a script-backed model or not.

LoadFromDatabase(String, ModelExtractOptions, Nullable<CancellationToken>) LoadFromDatabase(String, ModelExtractOptions, Nullable<CancellationToken>) LoadFromDatabase(String, ModelExtractOptions, Nullable<CancellationToken>)

Loads a model from a database using the specified options.

LoadFromDatabase(String, SecureString, ModelExtractOptions, Nullable<CancellationToken>) LoadFromDatabase(String, SecureString, ModelExtractOptions, Nullable<CancellationToken>) LoadFromDatabase(String, SecureString, ModelExtractOptions, Nullable<CancellationToken>)

Loads a model from a database using the specified options.

LoadFromDatabaseWithAuthProvider(String, IUniversalAuthProvider, ModelExtractOptions, Nullable<CancellationToken>) LoadFromDatabaseWithAuthProvider(String, IUniversalAuthProvider, ModelExtractOptions, Nullable<CancellationToken>) LoadFromDatabaseWithAuthProvider(String, IUniversalAuthProvider, ModelExtractOptions, Nullable<CancellationToken>)

Loads a model from a database using the specified options.

Validate() Validate() Validate()

Validates the model and returns a list of messages with any errors/warnings.

Applies to