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: