[Feature] Copy objects from live Server to offline (design mode) Server
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 30/100
Línea de trabajo
Comienza con los puntos de entrada Server, Database, Table y Transfer mostrados en el issue, centrándote en el parenting del modo de diseño offline y en el comportamiento de las transferencias. Determina una forma compatible de copiar definiciones de objetos desde un servidor activo a un servidor offline y crear un script de la jerarquía resultante sin conectarte a una instancia de destino.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
It would be really great if there were a way to transfer object definitions from a live server to an offline server.
My use case is that I am designing an application which allows users to compile many database objects from different instances into a single hierarchy, then generate a script to create that hierarchy on an arbitrary instance of SQL Server.
To accomplish this, I was hoping to add the online objects selected by the user to an offline (design mode) Server, then use SMO's scripting capabilities to script the entire tree to a .sql file.
For example:
var onlineServerConnection = new ServerConnection(new SqlConnection(/* ... */));
var onlineServer = new Server(onlineServerConnection);
var onlineDatabase = onlineServer.Databases["SmoTestDatabaseOnline"];
var onlineTable = onlineDatabase.Tables["SmoTestTable"];
var offlineServerConnection = new ServerConnection { ServerVersion = new ServerVersion(15, 0), TrueName = "designMode" };
var offlineServer = new Server(offlineServerConnection);
(offlineServer as ISfcHasConnection).ConnectionContext.Mode = SfcConnectionContextMode.Offline;
var offlineDatabase = new Database
{
Parent = offlineServer,
Name = "SmoTestDatabaseOffline"
};
onlineTable.Parent = offlineDatabase;
offlineDatabase.Tables.Add(onlineTable);
offlineServer.Databases.Add(offlineDatabase);
But I'm met with Microsoft.SqlServer.Management.Smo.FailedOperationException: SetParent failed for Table 'dbo.SmoTestTable'. ---> Microsoft.SqlServer.Management.Smo.InvalidSmoOperationException: Cannot perform the operation on this object, because the object is a member of a collection..
If I remove the onlineTable.Parent = offlineDatabase;, I am instead met with Microsoft.SqlServer.Management.Smo.FailedOperationException: Parent property of object [dbo].[SmoTestTable] does not match the collection's parent to which it is added.
I also attempted to use the Transfer class to accomplish this, but was met with Microsoft.SqlServer.Management.Common.TransferException: An error occurred while transferring data. See the inner exception for details. ---> Microsoft.Data.SqlClient.SqlException (0x80131904): A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
var onlineDatabase = onlineServer.Databases["SmoTestDatabaseOnline"];
var onlineTable = onlineDatabase.Tables["SmoTestTable"];
//--------------------------------------------------
var transfer = new Transfer(onlineDatabase)
{
DestinationServer = offlineServer.Name,
DestinationDatabase = offlineDatabase.Name,
CopyAllObjects = false,
CopySchema = true
};
transfer.ObjectList.Add(onlineTable);
transfer.TransferData();
offlineServer.Refresh();
offlineDatabase.Refresh();
As it stands, the only conceivable way to accomplish what I want to do would be to create a new Table object and individually copy all properties onlineTable to it. But this is cumbersome and prone to error.
- Lenguaje dominante
- C#
- Estrellas
- 143
- Forks
- 28
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de microsoft/sqlmanagementobjects
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 72/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 74/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 78/100
-
Dificultad 3/5 1-2 días Aptitud para principiantes 68/100
Todos los issues de microsoft/sqlmanagementobjects
Issues similares
-
Add more to the documentation Abierto:watch: Not Triaged dotnet-fsharp/svc
Dificultad 1/5 Menos de una hora Aptitud para principiantes 90/100
-
Client customer-reported needs-team-attention question Service Attention WebPubSub
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Azure/azure-sdk-for-net#63292 · 3 comentarios · 1 reacción ·
-
Issue-Enhancement Needs-Triage
Dificultad 1/5 Menos de una hora Aptitud para principiantes 86/100
PowerShell/PowerShell#28061 · 2 reacciones ·
-
dependencies needs-team-triage server-Azure.Mcp
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
-
aspnet-core/svc aspnetcore-signalr/subsvc doc-enhancement Pri2 SignalR
Dificultad 1/5 Menos de una hora Aptitud para principiantes 88/100
dotnet/AspNetCore.Docs#37729 ·