We recently spun up a multi-site instance of Sitefintiy 8.0 and encountered an issue where we were unable to enable some dynamic modules for some of the additional sites that we created. We found that this was happening because the dynamic provider names that were being generated already existed.
We found a workaround for this and wanted to put it out here because it looks like a possible bug with how Sitefinity is generating provider names. This had us spinning out for a few days.
Steps to reproduce on our end:
1) Created a DynamicModule (e.g. rotators)
2) Went to "Manage" sites under the multisite dropdown in the admin.
3) For one of the additional sites we selected Action > Configure Modules
4) Enabled the DynamicModule (e.g. rotators) to the site.
Result: Error, "An item with the same key has already been added"
In Administration > Settings > Advanced > DynamicModules > Providers, I could see a listing of the providers that were already existing:
dynamicProvider2, dynamicProvider3, 4, 8, 7. Where some of the numeric postfixes were missing (maybe from a site or module being disabled through the multi-site settings).
After digging into some of the sitefinity dlls I found that an internal "GenerateProviderName" (In Telerik.Sitefinity.Data.ManagerExtensions) method was adding the post fix via
"int num = existringProviderNames.Count<string>() + 1"
This is a problem if there are removed providers because that number will circle around and duplicate.
The work around for us was to add additional placeholder providers in the settings to increase this iterator. But it may be beneficial to have this logic changed to do +1 off the highest postfix and not the count.
var name =
var index = existringProviderNames.Count() + 1;
name = baseProviderName + index;