Error when attempting to log in to Sitecore after security database is moved


Description

Logging in to Sitecore XP with some external user (AzureAD, for example) might fail with an unhandled exception after moving the security database. The error occurs due to the missing UserLogins table. The following message can appear in the log:

Exception: System.Exception
Message: Invalid object name 'UserLogins'.
Source: Sitecore.Kernel
at Sitecore.Data.DataProviders.Sql.DataProviderCommand.ExecuteReader()
at Sitecore.Data.DataProviders.Sql.DataProviderReader..ctor(DataProviderCommand command)
at Sitecore.Data.DataProviders.Sql.SqlDataApi.<>c__DisplayClass29_0.<CreateReader>b__0()
at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action, Action recover)
at Sitecore.Data.DataProviders.Sql.SqlDataApi.CreateReader(String sql, Object[] parameters)

Solution

To resolve the issue, consider the following workaround:

  1. Open Microsoft SLQ Server Management Studio.
  2. Connect to the server hosting the current Security table.
  3. Right-click the UserLogins table.
  4. Click Script Table as, then CREATE To, and then New Query Editor Window.
  5. Run the resulting script against the new Security database to add the UserLogins table.