Search code examples
visual-studio-2013sql-server-data-tools

SQL71501 Adding a Role Membership in SSDT VS2013


I am trying to add a role membership with my SSDT database project.

EXECUTE sp_addrolemember @rolename = N'<RoleName>', @membername = N'<Domain>\svc.data'

I get the following error:

SQL71501: Role Membership: <unnamed> has an unresolved reference to object [<Domain>\svc.data]

The user and logins are defined and if I switch the code to another user ie:

EXECUTE sp_addrolemember @rolename = N'<RoleName>', @membername = N'<Domain>\svc.data2'

It works perfectly.

I have reimported the schema from the live database (the live database works fine) and I get the same error.


Solution

  • I just found out what you can try. But make sure you have latest SSDT power tools installed:

    1) Create a folder like Security

    2) Right-click, then Add -> New Item

    3) Under SQL Server -> Security

    There is a Server Role type file and Server Role Membership. Let me know if that helps.

    I used that to create the Database Role, moved out the scripts out of the post-deploy and it all worked well. I was also granting the permissions in the same file, just had to use GO separator after each line.