Unable to host an NServiceBus Saga from another Service with SQL Persistence

I am attempting to host a Saga from one project in another project using NServiceBus 6 with SqlPersistence and SqlDialect.MsSqlServer. In most examples I have found, the Saga is contained in the same assembly as the hosting app, and perhaps this is why I am struggling.

When hosting everything in the same app, the NServiceBus.Persistence.Sql.MsBuild package correctly outputs Saga .sql files during the build and then picks these up and executes them on run. Using a separate app, only the Outbox, Subscription and Timeout .sql files are generated, not the Saga ones. The following entry is then logged on run:

INFO NServiceBus.Persistence.Sql.Installer Directory ‘[PATH]\SagaPersistence\Service\bin\Debug\NServiceBus.Persistence.Sql\MsSqlServer\Sagas’ not found so no saga creation scripts will be executed.

A full VS 2017 repro may be found at GitHub - WolfyUK/NServiceBusSagaSqlPersistence.

Firstly, is it a bad idea to host a Sagas from another service, rather than being self-hosted? If not, can someone advise the best way to resolve the SQL Persistence issue?

Hi Marc,

Can you add NServiceBus.Persistence.Sql.MsBuild to the Saga project? The scripts should then be found there. Unfortunately they’re not copied to the host its folder, so you’ll have to take them from there into production. Or have them generated by using EnableInstallers, like you’re already doing.

Hello Dennis, as similar to the question here, I have included the NServiceBus.Persistence.Sql package to the project that contains sagas and I can see it generates Outbox, Subscription and Timeout scripts perfectly but Sagas folder is empty. Is it looking for any particular type of Saga or initialization to generate?

Here is my assembly info in the project.
[assembly: SqlPersistenceSettings(MsSqlServerScripts = true, ProduceSagaScripts =true, ProduceOutboxScripts =true, ScriptPromotionPath = “$(SolutionDir)PromotedSqlScripts”)]

I can see everything (except Saga’s) are dropping into that folder.

Hi @Arthur_Cam. We chatted today briefly about this. I’m testing out the script generator locally and I’m still no further to a solution. Can you try the simple SQL persistence sample (Simple SQL Persistence Usage • Sql Persistence Samples • Particular Docs) and see if that generates the saga scripts for you? Note that the sample includes endpoints for MySql, SQL Server, PostgreSQL, and Oracle so when you open the sln in Visual Studio, you can remove the ones that aren’t relevant for you. After building the solution, check the PromotedSqlScripts folder. There should be two files in the Sagas folder.

In the meantime, I’ll keep looking at my end to see if I can find something else that might be blocking things.