Home Forums Programming SSDT Difficulties creating working database project in SSDT RE: Difficulties creating working database project in SSDT

  • kyagi.jo - Thursday, August 10, 2017 3:40 AM

    Hi,

    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.

    I keep users and logins out of DB projects, as they vary between environments.
    I have separate scripts which fix this stuff up, along with assigning users to DB roles, after deployment.
    Any schemas I create are owned by dbo. Why do you need user-owned schemas?
    Cross-database references are kept to a minimum (eg, to a separate 'utilities' database).

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.