Specify schema name in Service Control (using SQL Server Transport)

From the documentation I can’t find a way to tell ServiceControl which database schema to use. Ours is named ‘transport’, but after creating the SC instance it uses ‘dbo’ (e.g. created different error queues, than the endpoints use).

How can I tell ServiceControl which database schema to use for the SQL Server Transport?

Hi Philipp

You can add Queue Schema to the connection string.

Data Source=<SQLInstance>;Initial Catalog=nservicebus;Integrated Security=True;Queue Schema=YourSchema

I’ll PR this against the sample connection string in ServiceControl to make it more visible

Regards
Daniel

Here we go

Daniel

1 Like

Thanks, Daniel.

Can this be used for the Endpoints instead of the ‘DefaultSchema()’ of the transport configuration as well? So that we would only need to have 1 connection string per environment for all uses, SC and endpoints

Unfortunately not out of the box. You would have to write code like the following for your endpoints

var builder = new DbConnectionStringBuilder
{
    ConnectionString = connectionString
};

if (builder.TryGetValue(queueSchemaName, out var customSchema))
{
    builder.Remove(queueSchemaName);

    transport.DefaultSchema((string)customSchema);
}

transport.ConnectionString(builder.ConnectionString);

Hope that helps. have a nice day and don’t melt away!

Daniel

1 Like

Thanks, you too.

A/C for the win :slight_smile:

I am using ServiceControl 1.47.5 and also provided queue schema in the connection string but still when I retry exception message from ServiceInsight I am getting error for invalid object and it always look queue in dbo schema.

ServiceBus.Unicast.Queuing.QueueNotFoundException: Failed to send message to address: [xxx.xxx.xxxx] ---> System.Data.SqlClient.SqlException: Invalid object name 'dbo.xxx.xxx.xxxx'.

Hi Raj

Please have a look at our supported versions page

The version of ServiceControl you are using is out of support. It might be that this specific version doesn’t support the queue schema I mentioned

Regards
Daniel