I have managed to fix this by putting in the line
AuthenticationHelper.ImportExternalRoles = false; in the CMSAppBase.cs file. Context shown below:
if (siteName != "")
// If authentication mode is Windows, set user UI culture
if (RequestHelper.IsWindowsAuthentication() && UserInfoProvider.IsAuthenticated())
AuthenticationHelper.ImportExternalRoles = false; // LINE INSERTED HERE TO FIX ISSUE
UserInfo currentUser = CMSContext.CurrentUser;
I guess what this does is it prevents external roles being imported into the CMS_Role table. However, this is not really desired if possible as we would still want roles to be imported. We weren't having issues without this setting being set to false in the previous version so is there something in the newer versions which is importing external roles in a different way that is causing a 'CodeNameNotUniqueException'?