Contributor: hudajazmawi vittorionoca_msftit
Overview
Exporting an Azure SQL Database to a BACPAC using SqlPackage / SSMS may fail when Change Data Capture (CDC) is enabled and database users (or Entra groups) are assigned to CDC-related roles such as db_cdcreader.
A common error observed:
Error SQL71501: Error validating element:
Role Membership: has an unresolved reference to Role [db_cdcreader].
This issue can be confusing because:
- The database is healthy
- CDC is functioning correctly
- The error occurs only during export
Scenario
From a real customer case:
- Azure SQL Database with CDC enabled
- An Entra (AAD) group added to db_cdcreader
- Export attempted via SqlPackage (v170+)
- Export fails during schema validation phase
Root Cause Explained
1. SqlPackage performs strict schema modeling
During export, SqlPackage (via DacFx) builds a logical schema model of the database.
- Every object must be fully resolvable
- Roles and role memberships are validated
- Any missing/unsupported object → export fails
This is why the error appears as:
SQL71501 – unresolved reference
2. CDC introduces system-managed objects
When CDC is enabled, SQL automatically creates:
- cdc schema
- System tables
- Special roles:
- db_cdcreader
- cdc_admin
These objects are not treated as regular user-defined objects:
- They are system-managed
- Some are implicitly created
- Some are not fully modeled/exported by DacFx
3. Role membership is the breaking point
The failure does not happen because the role exists
It happens because:
- The role membership exists (e.g., Entra group → db_cdcreader)
- But the role itself is not included or resolved in the export model
Result:
Membership → cannot resolve target role → validation failure (SQL71501)
This behavior aligns with documented patterns where CDC roles are excluded or not recognized during BACPAC export.
Reproducing the Issue
You are likely impacted if:
- CDC is enabled
- Users or Entra groups are assigned to:
- db_cdcreader
- cdc_admin
- Export is attempted via:
- SqlPackage
- SSMS “Export Data-tier Application”
Workarounds
Option 1: Temporarily remove role membership
Remove the CDC role membership before export:
ALTER ROLE db_cdcreader DROP MEMBER [your_user_or_group];
Run export, then reassign:
ALTER ROLE db_cdcreader ADD MEMBER [your_user_or_group];
This is the simplest and most reliable workaround
Confirmed in Microsoft Q&A guidance for CDC roles
Option 2: Export from a cleaned database copy
If you cannot modify production (e.g., tooling restrictions):
- Create a database copy
- Remove CDC-related role memberships
- Export from the copy
Recommended when:
- Using automation tools (e.g., Commvault)
- Production changes are restricted
Option 3: Cleanup unsupported references
General best practice:
- Remove unsupported / system-bound references before export
- Especially:
- CDC role memberships
- Legacy system objects
Option 4: Use SqlPackage with ExtractAllTableData=True
Another practical workaround is to leverage the SqlPackage option ExtractAllTableData=True, which allows you to extract all data from all user tables.
- When set to True:
- Data is extracted from all user tables
- You cannot specify individual tables
- When set to False (default):
- You can selectively extract data from specific tables only
- This reduces exposure to unsupported or problematic objects during validation
Example
SqlPackage /Action:Extract
/SourceServerName:<server>
/SourceDatabaseName:<database>
/TargetFile:<output.bacpac>
/p:ExtractAllTableData=True
- Additional Validation: CDC Role Ownership
When investigating export failures involving CDC roles, it is also recommended to verify the ownership of the db_cdcreader role.
SqlPackage relies on schema metadata to determine whether an object should be treated as a system-managed CDC object or as a user-defined database object during model validation. If the ownership of db_cdcreader has been changed from its default value, SqlPackage may not correctly identify it as a system CDC role, which can contribute to validation errors such as SQL71501.
How to Validate
SELECT
name,
USER_NAME(owning_principal_id) AS role_owner
FROM sys.database_principals
WHERE name = 'db_cdcreader';
Expected result:
db_cdcreader dbo
If the role owner is not dbo, the following can be used as a resolution:
Resolution
“
ALTER AUTHORIZATION ON ROLE::[db_cdcreader] TO [dbo];
“
Maintaining the default ownership ensures that SqlPackage can correctly recognize db_cdcreader as a system-managed CDC role during export operations
When to use this option
- When the export fails due to CDC roles or related schema validation issues (SQL71501)
- As a targeted workaround when full export is blocked
Important Considerations
- This is not a runtime database issue
- It is a schema validation limitation in DacFx / SqlPackage
- CDC itself is supported, but:
- Certain security objects are not fully exportable
Key Takeaways
- SQL71501 during export is often a model validation issue, not a data issue
- CDC roles (db_cdcreader, cdc_admin) can break export due to partial modeling
- The failure is triggered by role membership, not CDC itself
- Workarounds involve:
- Removing memberships
- Exporting from a cleaned copy