internal static void SetAmbientScope(DbContextScope newAmbientScope) {
if (newAmbientScope == null)
throw new ArgumentNullException(nameof(newAmbientScope));
var current = GetIdentifier();
var id = newAmbientScope._instanceIdentifier;
if (current == id)
return;
// Store the new scope's instance identifier in the CallContext, making it the ambient scope
SetId(id);
// Keep track of this instance (or do nothing if we're already tracking it)
dbContextScopeInstances.GetValue(id, key => newAmbientScope);
}