Foreign keys disappear following replication

  • I have a merge replication configuration. The publication database has a number of tables, some of which contain foreign keys. I build my subscriber database with exactly the same configuration as the publisher. All foreign key configurations are the same.

    Once I add the new database as a subscriber of the publication database, a number of the foreign keys disappear.

    Can anyone advise why this occurs and how I can retain the foreign keys?

    Thanks.

  • Pete Bishop - Monday, September 25, 2017 10:12 AM

    I have a merge replication configuration. The publication database has a number of tables, some of which contain foreign keys. I build my subscriber database with exactly the same configuration as the publisher. All foreign key configurations are the same.

    Once I add the new database as a subscriber of the publication database, a number of the foreign keys disappear.

    Can anyone advise why this occurs and how I can retain the foreign keys?

    Thanks.

    Could the 'not for replication' property be affecting this?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Hi Phil. No, we're not using that setting and we do have schema changes enabled for replication.

  • Pete Bishop - Monday, September 25, 2017 10:12 AM

    I have a merge replication configuration. The publication database has a number of tables, some of which contain foreign keys. I build my subscriber database with exactly the same configuration as the publisher. All foreign key configurations are the same.

    Once I add the new database as a subscriber of the publication database, a number of the foreign keys disappear.

    Can anyone advise why this occurs and how I can retain the foreign keys?

    Thanks.

    Did you check the article properties for the publication and check the setting for Copy Foreign Key Constraints?
    Also I don't think the foreign keys replicate if the referenced tables are not included in the publication

    Sue

  • Sorry for the delay; forgot to update this.
    This turned out to be a strange issue. The publication database had a number of duplicated foreign keys on several tables and I carried out a clean-up exercise to delete the unnecessary duplicates. However, when replication executed it processed the delete command and removed all of the previously-duplicated foreign keys. The only solution was to delete all foreign keys that were duplicated and then create the non-duplicated version of the keys again.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply