static void SendSomeMessages(ISyncBus bus) { var now = DateTime.Now; bus.SendLocal($"Outside context msg 1, the time is {now}"); using (var context = new CustomDbContext()) { // send some messages bus.SendLocal($"Custom db context msg 1, the time is {now}"); bus.SendLocal($"Custom db context msg 2, the time is {now}"); bus.SendLocal($"Custom db context msg 3, the time is {now}"); bus.SendLocal($"Custom db context msg 4, the time is {now}"); bus.SendLocal($"Custom db context msg 5, the time is {now}"); context.Commit(); } }