-
Notifications
You must be signed in to change notification settings - Fork 23
Closed
Description
Over the years, "design mode" has been neglected such that SMO requires a live connection to a server in order to construct an object hierarchy and generate scripts for it.
EG this throws an exception during Script():
// setting ServerVersion allows setting Database.Parent without a server query to get the version
// set TrueName to ensure the URN that identifies the Server is complete
var serverConnection = new ServerConnection() { ServerVersion = new ServerVersion(15, 0), TrueName = "designMode" };
var server = new Management.Smo.Server(serverConnection);
// designmode requires an offline connection
(server as ISfcHasConnection).ConnectionContext.Mode = SfcConnectionContextMode.Offline;
var database = new Database()
{
Parent = server,
Name = "dbname"
};
var script = database.Script();it should output CREATE DATABASE [dbname]
Metadata
Metadata
Assignees
Labels
No labels