SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Difficulties creating working database project in SSDT


Difficulties creating working database project in SSDT

Author
Message
kyagi.jo
kyagi.jo
SSCommitted
SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)SSCommitted (1.6K reputation)

Group: General Forum Members
Points: 1614 Visits: 532
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.
Phil Parkin
Phil Parkin
SSC Guru
SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)SSC Guru (172K reputation)

Group: General Forum Members
Points: 172372 Visits: 23542
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).



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum








































































































































































SQLServerCentral


Search