public string GetTMSL(TOM.Database db, TOM.Server server, string targetDatabaseName, DeploymentOptions options, bool includeRestricted = false) { if (db == null) { throw new ArgumentNullException("db"); } if (string.IsNullOrWhiteSpace(targetDatabaseName)) { throw new ArgumentNullException("targetDatabaseName"); } if (options.DeployRoleMembers && !options.DeployRoles) { throw new ArgumentException("Cannot deploy Role Members when Role deployment is disabled."); } if (server.Databases.ContainsName(targetDatabaseName) && options.DeployMode == DeploymentMode.CreateDatabase) { throw new ArgumentException("The specified database already exists."); } options.RemoveRoleMemberIds = server.IsAzure(); // Role member MemberID properties must not be assigned when deploying to Azure / Power BI. string tmsl; db.AddTabularEditorTag(); if (!server.Databases.ContainsName(targetDatabaseName)) { tmsl = GetDeployNewTMSL(db, targetDatabaseName, options, includeRestricted, server.CompatibilityMode); } else { tmsl = DeployExistingTMSL(db, server, targetDatabaseName, options, includeRestricted, server.CompatibilityMode); } return(tmsl); }