"Unresolved reference to User" after importing as a VS DB project
The easiest way is to not manage users through ssdt (most people don't). So you can just strip them out and don't deploy logins or users.
There are three ways:
- the new options to ignore users/logins
- write a deployment contributor to pull them out
- use my deployment contributor http://agilesqlclub.Codeplex.com
Ed
I had the same problem and found this link
User has an unresolved reference to Login
If you create application specific logins (which you should) then you are going to come across this error when trying to build your solution. To correct this error, select include 'Non-Application-scoped' object types in the options (gear icon at top) when you do a schema compare (right-click the database project to find Schema Compare). You can then just import the logins into your regular project, and the references are sorted. Note: If you click on the Object Types tab and it closes the dialog (which it did for me), instead use the tab key until Application-scoped is highlighted, then press the down arrow to highlight Non-Application-scoped and press the space bar. Now you should be able to click OK and see the logins.
Apparently, this issue is still occurring on VS2017 database projects as well.
I've managed to solve it by first creating the login and then create the user.
-- Windows Account
CREATE LOGIN [Domain\Username]
FROM WINDOWS WITH DEFAULT_LANGUAGE = [us_english];
GO
CREATE USER [Domain\Username] FOR LOGIN [Domain\Username];
GO
-- Sql Acccount
CREATE LOGIN [sql_account] WITH PASSWORD = 'Ch@ngeth1spA$swurD'
GO
CREATE USER [sql_account]
FROM LOGIN [sql_account]
WITH DEFAULT_SCHEMA = dbo
GO
-- Then set the sql file Build Action to "Build"