I have several databases on one of my servers that I am trying to create database projects for, so that I can keep track of changes using the schema compare tools.
It seems to be causing a lot of issues while creating the logins.
I create the projects by adding a database project to the solution, setting the project to be SQL server 2012 in 2008 compatibility mode (same as our databases) and then try to import the database, importing referenced logins, as well as importing the application-scoped objects only.
For my first two databases I tried, it looked to work ok, and the projects were buildable, but after importing one of the larger projects, then it looks like the projects are having issues with declaring logins multiple times, within the projects. I don't see how I can get around this - searching on the internet, some people have suggested that I separate this out into another common project, and reference that, but my project seems to ignore this.
The error when I look at the "CREATE LOGIN" line is:
SQL71508:The model already has an element that has the same name <login name>
If I remove the line for the creation of the SQL login from the current project, then the CREATE USER FOR LOGIN <login name> fails because it does not think the login exists. (SQL71501: User <user name> has an unresolved reference to Login <login name>.
I cannot omit the login information altogether from the database project, as some of the stored procedures run under user owned schemas, so the user is meant to exist.
I think this might work ok, if I didn't have to reference other databases which have these common login elements, but I do, as stored procedures commonly refer to the other databases, so I need to create a database reference them.
Has anyone got any suggestions that might help with these issues? I'm working through other errors to get the project to build, but I am finding myself stumped on this one, and it is surprising, as the database project seems unable to handle what feels like a relatively standard setup for SQL user logins - it is just a single login, with access through being a SQL user in multiple databases, I'm not sure what I could change to get past this build error.