You are here
Home > Programming > Backwards Compatibility of SQL Server Management Objects (SMO)

Backwards Compatibility of SQL Server Management Objects (SMO)

Fallback Image

Visual Studio Add Reference SMO

As a minimum, you would need to add the following which are required for connection classes, SMO utility classes, and foundation classes:

  • Microsoft.SqlServer.ConnectionInfo
  • Microsoft.SqlServer.Smo
  • Microsoft.SqlServer.Management.Sdk.Sfc

According to Microsoft, the SmoEnum.dll has been removed and some namespaces have changed. You will need to include the following:

In Visual C#

[sourcecode language=”csharp”]

using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Common;

[/sourcecode]

In Visual Basic

[sourcecode language=”vb”]

Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Common

[/sourcecode]

Lastly, if your application uses the Urn functionality (for example Server.GetSqlSmoObject(Urn)) you will need to link to the Microsoft.SqlServer.Management.Sdk.Sfc namespace. If you use the Transfer object directly, you need to link to the Microsoft.SqlServer.Management.SmoExtended namespace. (Example of the Transfer object)

[sourcecode language=”csharp”]
//Define a Transfer object and set the required options and properties.
Transfer xfr;
xfr = new Transfer(db);
xfr.CopyAllTables = true;
xfr.Options.WithDependencies = true;
xfr.Options.ContinueScriptingOnError = true;
xfr.DestinationDatabase = "AdventureWorks2012Copy";
xfr.DestinationServer = srv.Name;
xfr.DestinationLoginSecure = true;
xfr.CopySchema = true;
//Script the transfer. Alternatively perform immediate data transfer
// with TransferData method.
xfr.ScriptTransfer();
[/sourcecode]

Expect some code changes when you migrate code. The reason for this is that some features have been depreciated in the new DLL’s.

Dirk Strauss
Dirk is a Software Developer from South Africa. He loves all things Technology and is slightly addicted to Jimi Hendrix. Apart from writing code, he also enjoys authoring books and articles. "I love sharing knowledge and connecting with people from around the world. It's the diversity that makes life so beautiful." Dirk feels very strongly that pizza is simply not complete without Tabasco, that you can never have too much garlic, and that cooking the perfect steak is an art he has almost mastered.
https://dirkstrauss.com

Similar Articles

Top