'Visual Studio errors SQL71501 and SQL71508 with a certificate?

I've seen problems like these with users before, but never with a certificate. I have a simple certificate with no keys:

CREATE CERTIFICATE [FOO_EXPORT]
AUTHORIZATION [dbo]
WITH SUBJECT = N'FOO Export', START_DATE = N'2022-05-01T06:12:30', STOP_DATE = N'2032-05-01T06:12:30'

This same certificate exists in three databases. For one database only I've suddenly begun getting the below errors despite having no prior issues with my certificate. This database is the only one where the certificate is used. It is used to sign four functions.

SQL71501: SqlSignatureEncryptionMechnaism: <unnamed> has an unresolved reference to Certificate [FOO_EXPORT]. --Thrown by Signatures.sql
SQL71501: SqlSignatureEncryptionMechnaism: <unnamed> has an unresolved reference to Certificate [FOO_EXPORT]. --Thrown by Signatures.sql
SQL71501: SqlSignatureEncryptionMechnaism: <unnamed> has an unresolved reference to Certificate [FOO_EXPORT]. --Thrown by Signatures.sql
SQL71501: SqlSignatureEncryptionMechnaism: <unnamed> has an unresolved reference to Certificate [FOO_EXPORT]. --Thrown by Signatures.sql
SQL71501: User: [FOO_USER] has an unresolved reference to Certificate [FOO_EXPORT]. --Thrown by FOO_USER.sql
SQL71508: The model already has an element that has the same name FOO_EXPORT. --Thrown by FOO_EXPORT.sql

As for what FOO_USER.sql is, it's quite simple:

CREATE USER [FOO_USER] FOR CERTIFICATE [FOO_EXPORT];

an identical file for this exists in all three of my databases.

Signatures.sql is unremarkable. It's just four blocks of

ADD SIGNATURE TO OBJECT::[FOO_SCHEMA].[FUNCTIONNAME]
BY CERTIFICATE [FOO_EXPORT] WITH SIGNATURE = INCOMPREHENSIBLEPASSWORD;

As for the last error, I've searched high and low, but I can see no other relevant references to FOO_EXPORT. The entire solution has eight references to it. Six of them are the three FOO_USER.sql and FOO_EXPORT.sql files that I've shown above (two for each of the three databases). The other two only exist in the databases that aren't throwing the error:

databaseName.sqlproj(87): <Build Include="Secruirty/FOO_EXPORT.sql" />
otherDatabaseName.sqlproj(188): <Build Include="Secruirty/FOO_EXPORT.sql" />

Building/Rebuilding does nothing to help. Aside from obvious junk, schema compares with every box ticked only claim that I'm missing a User. Letting the compare update the project does nothing. The compare claims that the user has a missing property, namely a certificate. The schema compare says that the definition of the certificate (which is a property of the user) is just FOO_EXPORT with no other text whatsoever.

Is there any known solution to this?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source