After creating a Database Project in Visual Studio and importing all database objects, we got one error:
“SQL03006: User: [x] has an unresolved reference to Login [X]”
If I double click on the error, it takes me to a CREATE USER statement in one of the files. The problem is that the LOGIN that it's referencing is a SERVER object, not a DATABASE object and your can't run server based SQL commands in a database project type.
How can you solve this?
- Right click on your solution and choose Add -> New Project. For the project type select "SQL Server 2008 Server Project."
- Do a schema compare against the server project and get it all synchronized.
- Go back do your database project and right click on References and "Add Database Reference" and select your server project.
- That’s it!
What you can also do is turn off schema checking (Tools->Options->Database Tools->Schema Compare->SQL Server, then the Object Type tab) for anything user or security related since that is usually done by a DBA.