Ian
Ian

Reputation: 3149

Azure Sql database schema missing constraints after schema compare

I created a blank SQL database in Azure.

From Visual Studio 2017, I performed a Schema Compare, and updated the blank Azure database to my schema. There were no errors so I didn't check everything was exactly the same.

I setup replication and replicated all data fine.

Upon performing another schema compare, I discovered that all foreign key constraints are missing, along with default values and indexing.

Upvotes: 2

Views: 351

Answers (1)

Ian
Ian

Reputation: 3149

It appears that the initial snapshot taken for replication does not replicate constraints and default values, due to entity replication being done in an arbitrary order; these constraints would cause errors.

After removing seed column NOT FOR REPLICATION using

ALTER TABLE [dbo].[ColumnName] ALTER COLUMN Id DROP NOT FOR REPLICATION;

I could do another schema compare to re-apply all constraints and default values.

Upvotes: 1

Related Questions