Visual Studio 2010 - Database Project with imported database fails to build

Matt Roberts picture Matt Roberts · Mar 29, 2011 · Viewed 16.3k times · Source

I'm looking at the Database Project in VS2010, the idea being that I want something I can use to keep track of the database schema (in source control) and the ability to generate "new install" scripts, and change scripts.

When I create a new database project wizard and import my existing database schema, it won't "build". I get the error:

SQL03006: User: [scanner] has an unresolved reference to Login [scanner].

The SQL that generates this error:

CREATE USER [scanner] FOR LOGIN [scanner];

The user "scanner" is a login defined in the database I imported. I have no idea what it's teling me, and google isn't throwing much up. Any ideas?

Answer

Judah Sali picture Judah Sali · Mar 29, 2011

The Login is actually defined in the master database of the server install. The CREATE USER statement needs to point at an existing Login otherwise it errors. The Database Project is not aware of the Login at the server level. Either you can create a Server Project to handle the Logins, or you can turn off the checking of Security objects in your Database Project. See the answer by Demetri M for more details: http://social.msdn.microsoft.com/Forums/eu/vstsdb/thread/1f8226fe-b791-4344-8735-3d38307e8664