microsoft / microsoft/vscode-mssql

[Bug]: Schema Compare shows false diff on default constraint comparing DACPAC (source) to .sqlproj (target)

Open
#22,916 2 comments 0 reactions 1 assignee Claimed by @aasimkhan30 View on GitHub
Area - Schema Compare Bug Triage: Needed User-filed
Dominant language
TypeScript
Stars
1.9k
Forks
610
Avg merge
2d 3h
Merged PRs (30d)
97

Description

### Description

Schema Compare reports a difference on a column's default constraint when comparing a .dacpac (source) against a .sqlproj (target), even though the constraint is identical on both sides when verified independently.

Expected: Schema Compare should recognize the default constraint as identical between the DACPAC and the built .sqlproj model, and not report a difference.

Actual: The comparison result shows the column without its CONSTRAINT [DF_...] clause on one side (see attached screenshot), implying it's missing, when it is not.

Verification that this is a false positive:
- Extracted the source database to a .dacpac two ways — via the VS Code Extract wizard, and via standalone sqlpackage /Action:Extract (bypassing the extension) — and unzipped both. model.xml in both shows the DF_ default constraint present and correctly defined on the LoadDate column.
- Confirmed directly against the source database via sys.default_constraints that the constraint genuinely exists with the expected definition.
- The .sqlproj's table definition file also contains the CONSTRAINT [DF_...] clause on the same column (visible on the target side of the Schema Compare diff itself).
- This rules out both the DacFx extraction engine and the VS Code Extract wizard as sources of the discrepancy, isolating the issue to Schema Compare's dacpac-vs-sqlproj comparison logic.

Attachments: screenshot of the Schema Compare false diff, model.xml excerpt from the source .dacpac showing the DF_ constraint.

Image

Image

### Steps to Reproduce

1. Extract a .dacpac from a SQL Server database containing a table with a column that has a default constraint (e.g. [LoadDate] DATETIME NOT NULL CONSTRAINT [DF_...] DEFAULT (...)).
2. Open Schema Compare in VS Code (MSSQL extension).
3. Set the extracted .dacpac as Source.
4. Set an existing .sqlproj (containing the same table/column/constraint) as Target.
5. Run Compare.
6. Observe the diff for the affected table: the default constraint clause appears missing/different on one side.

### Affected Area

- [ ] Connection dialog (SQL Server | Azure browse/Fabric browse)
- [ ] Query editor
- [ ] Query results panel
- [ ] Object Explorer
- [ ] GitHub Copilot integration
- [ ] Preview/Edit data
- [ ] Table Designer
- [ ] Schema Designer
- [x] Schema Compare
- [ ] Local SQL Server Container provisioning
- [ ] SQL database in Fabric provisioning
- [ ] DACPAC/BACPAC export/import
- [ ] SQL Database projects
- [ ] Query Plan Visualizer
- [ ] Other (please describe below)

### If you selected "Other", please describe the affected area

_No response_

### Environment Information

Environment:
- MSSQL Extension Version: 1.45.1
- VS Code Version: 1.137.0
- OS Version: Microsoft Windows 11 Enterprise - Version 10.0.26100 - Build 26100
- SqlPackage/DacFx version (standalone, used for verification): 170.5.76.0
- .sqlproj type: SSDT

### Confirmation

- [x] I have searched existing issues and couldn't find a match
- [ ] I want to work on this issue

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.