Ok so I made a grim discovery today, and I'm just not quite sure the best way to fix it.  I have some ideas, but before I launch into them, I thought I'd throw it through the feedback loop.

Scenario:

200 or so classes that are basically table-mapped entities.  So Account.cs, Location.cs, Customer.cs, etc.  Each one handles all the properties, retrieval, and persistence of its table.  These, as you can imagine, are referenced *everywhere*.

Private constructors, public static creation methods.  So the usage for "get all accounts" is List<Account> accounts = Account.GetAllAccounts(); and "get a single account" is Account account = Account.GetById(guid);

There is a static class CommonConfig that holds the current userid, and the current database connection string.  This is set at application startup on login, and then referenced inside the static creation methods of each entity.

Ok so this structure has been in place for a couple of years, and we've been happily using it without issue.

The issue discovered today though, is we are trying to do a web interface to some of the application functionality, and the static userid is being overwritten across the board when someone new logs in.  This is bad.

The userid isn't important for security so much as it's important to the createdby and lastupdatedby fields of any given row, as well as things like displaying the user name.

So what would be your thoughts on fixing this scenario with the least amount of impact to existing applications?