Cover the beans with water and let them soak overnight.
The next day, drain and rinse the beans and place them in a pot with enough water to cover. Add the baking soda and bring to a boil. Reduce the heat and simmer for 10 minutes. Drain and rinse. The beans should not be fully cooked at this point.
Preheat the oven to 300°F.
Place the chopped onion in the bottom of a 3-quart ovenproof casserole dish. Add half the bacon, followed by all the beans, and top with remaining bacon.
In a small bowl, combine the sugar, molasses, mustard, salt, and pepper. Mix well and pour this mixture over the beans. Without stirring, add just enough water to the casserole to barely cover.
Cover the dish and bake for 6 hours. Check the beans occasionally as you may need to add a little water, but be careful not to add too much.