I have Windows 10 Pro machine with SQL Server 2016 Dev installed. There are two local user accounts on the machine: [WORK\admin] and [WORK\erop]. [WORK\erop] account was created at first without connecting to Microsoft. But later I connect it to my MS account. [WORK\erop] account was added to sysadmin role when installing SQL Srv.
Now I try to connect to SQL Srv instance with SSMS as [WORK\erop] but receive:
Login failed for user 'MicrosoftAccount\<my_MS_account>'. Reason: Could not find a login matching the name provided. [CLIENT: <local machine>]
and
Error: 18456, Severity: 14, State: 5.
which means "Invalid userid".
As I guess SSMS is launched under MS account and since MS account has no login on SQL Srv instance it refuses connection.
I executed
CREATE LOGIN [MicrosoftAccount\<MS_account>] FROM WINDOWS WITH DEFAULT_DATABASE=[master], DEFAULT_LANGUAGE=[us_english]
GO
ALTER SERVER ROLE [sysadmin] ADD MEMBER [MicrosoftAccount\MS_account]
GO
and everything is OK. But I wonder are there any smarter way to map MS_account to local user that has a login on SQL Srv instance?