Remove a Per-Database Connection String
-
Use
RemoveConnectionStringOperationto remove a per-database connection string from the current database. -
A connection string cannot be removed while it is still used by an ongoing task.
Before removing it, delete the task or update it to use a different connection string. -
This operation cannot remove inherited server-wide connection strings.
To remove a cluster-level definition, use Remove a server-wide connection string. -
To remove a per-database connection string from Studio, open Settings > Connection Strings and use the remove action in the list view. See Managing per-database connection strings.
-
In this article:
Remove a per-database connection string
The following example removes a RavenDB per-database connection string.
Only the Name property is required; the type is inferred from the connection string class.
- Sync
- Async
var ravenConnectionString = new RavenConnectionString()
{
// Note:
// Only the 'Name' property of the connection string is needed for the remove operation.
// Other properties are not considered.
Name = "ravendb-connection-string-name"
};
// Define the remove connection string operation,
// pass the connection string to be removed.
var removeConStrOp
= new RemoveConnectionStringOperation<RavenConnectionString>(ravenConnectionString);
// Execute the operation by passing it to Maintenance.Send
store.Maintenance.Send(removeConStrOp);
var ravenConnectionString = new RavenConnectionString()
{
// Note:
// Only the 'Name' property of the connection string is needed for the remove operation.
// Other properties are not considered.
Name = "ravendb-connection-string-name"
};
// Define the remove connection string operation,
// pass the connection string to be removed.
var removeConStrOp
= new RemoveConnectionStringOperation<RavenConnectionString>(ravenConnectionString);
// Execute the operation by passing it to Maintenance.SendAsync
await store.Maintenance.SendAsync(removeConStrOp);
Syntax
public RemoveConnectionStringOperation(T connectionString) where T : ConnectionString
| Parameter | Type | Description |
|---|---|---|
| connectionString | T | Connection string to remove (only Name is required):RavenConnectionStringSqlConnectionStringSnowflakeConnectionStringOlapConnectionStringElasticSearchConnectionStringQueueConnectionStringAiConnectionString |
| Return value | Description |
|---|---|
RemoveConnectionStringResult | Contains RaftCommandIndex - the Raft index assigned to the operation. |