I don't think that loading all customer identifiers in memomy is a good idea. I would better implement it as a stored procedure:
1. Insert a record into [Customer] record with a stored procedure. Put all ID calculation and IDENTITY_INSERT logic there
2. Return a customer record from this stored procedure
3. Use this record in application to assign it to Guest customer role and any other logic
P.S. There's one more solution. But it'll require much more core changes. Do not use ID column in Customer table and make CustomerGuid as a primary key
1. Insert a record into [Customer] record with a stored procedure. Put all ID calculation and IDENTITY_INSERT logic there
2. Return a customer record from this stored procedure
3. Use this record in application to assign it to Guest customer role and any other logic
P.S. There's one more solution. But it'll require much more core changes. Do not use ID column in Customer table and make CustomerGuid as a primary key
I agree this is the best way to implement it. Database related issues should be handled on the database level. To minimize code changes, is it possible to do a sproc call at the end of DeleteGuestCustomers instead of being called upon Customer insertion? In this case, the sproc should be responsible for migrating individual customers with an Id of a large value to an Id of a smaller value in order to close gaps, loop through customers, and then reseed the identity. Is there any possible drawback in updating the Id of a registered customer? Just asking.