How to create a user for a login in 2013 SQL Server Database Project

旧时模样 提交于 2019-12-03 01:46:53

You can actually create the Server Level Login within the SQL Server Database Project using the standard T-SQL Syntax:

CREATE LOGIN [Login_Name] WITH PASSWORD = '<Password>';

Note: You can also right-click the database project and choose 'Add New Item' and navigate to SQL Server > Security (within the templates dialog) and select 'Login (SQL Server)'.

This resolves the SQL71501 Error and (assuming you are using SQLPackage.exe for deployment) will allow SQLPackage.exe the ability to compare the security object with the target Database before deployment and publishing occurs.

Hope that helps :)

If you are guaranteed to have the login on the server, your best bet is to tweak your master dacpac file. There are some instructions on how to do this here: http://sqlproj.com/index.php/2013/02/how-to-add-objects-to-master-dacpac

Alternatively, you could remove references to logins from the SSDT portion and handle it in post-deploy scripts. If you have any sort of environment where different permissions need to be applied in different server (Development, QA, Production), that might be the better option. I've blogged about this here: http://schottsql.blogspot.com/2013/05/ssdt-setting-different-permissions-per.html

Hopefully one of those will help. I've actually used the first option to work around an issue with needing to use EXECUTE AS, which requires that the user is in the project. It was a little tricky to get the exact XML, but I worked around it by creating an empty project with just that login, building it, and copying the XML from the dacpac into the master dacpac.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!