Skip to main content

Remove a Per-Database Connection String

  • Use RemoveConnectionStringOperation to 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.

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);

Syntax

public RemoveConnectionStringOperation(T connectionString) where T : ConnectionString
ParameterTypeDescription
connectionStringTConnection string to remove (only Name is required):
RavenConnectionString
SqlConnectionString
SnowflakeConnectionString
OlapConnectionString
ElasticSearchConnectionString
QueueConnectionString
AiConnectionString
Return valueDescription
RemoveConnectionStringResultContains RaftCommandIndex - the Raft index assigned to the operation.