We have been using Visual Studio Database projects for a while now and they work great for deployments. We have started capturing the current state of databases in different environments as dbschemas or dacpac files so we can reference them in other database projects and so we can see the state of production schemas without having production access.
Often I want to take a dbschema or dacpac from source control and create that schema on my local sql server but there are almost always errors due to users that exist in one environment and not my local. If I ignore user object types, I still get errors if anything else references the user (like schemas).
I’ve seen suggestions to create a server project to handle this case but I don’t want to create anything custom for this since I’m tasked to create a generic tool for our developers. I want to be able to take any dbschema or dacpac and import it with a “best-effort” attempt.
I understand this would be dangerous in most scenarios but on my local database I almost never care if there is data loss or other critical errors. I just want a fast way to get the valid objects in a dbschema on my local instance.
I know the exact problem that you are dealing with. In VS2010, when you use a dbschema file, I don’t beleive there is any way to do this other than create a server project (as you have said). You can, however, do a schema compare and choose not to compare users / logins, I beleive.
I have been using 2012 SSDT on my latest project and didn’t realize that this error disappeared until I read your question. When I imported an existing database, it appears that the users were not imported with it. Thus, when I publish the project, it is not deploying any users. What’s interesting though is that if you do a schema compare you have the option to compare users and deploy them. However, if you publish via the project (which I assume is using SqlProject.exe to publish) the users are not touched, even if you check Drop Objects in the Target that do not exist in the project.
My suggestion then is then to upgrade to the latest version of Database projects (available for 2010 and 2012), do not include users in the projects and use SqlPackage.exe to publish.
Hope this is helpful,
Mark