What are the challenges you face when working across database platforms? Take the survey

Dropping Constraints and Indexes

mtranmtran Posts: 34
I am trying to sync records between two tables in two different databases but I keep getting the UNIQUE_VALIDATION error/ UNIQUE KEY constraint.
session.Options.SqlOptions = (SqlOptions)sqloptions;

sqloptions is an enum that passed in as
DBSqlOptions.DropConstraintsAndIndexes | DBSqlOptions.ReseedIdentity | DBSqlOptions.DisableKeys | DBSqlOptions.UseTransactions

DBSqlOptions is an enum of SqlOptions

Why is this not working?



  • Options
    Thanks for your post.

    Are you also setting the provider options? These are the options that will be used when generating the migration script. e.g.

    provider.Options = session.Options;
  • Options
    Thanks! It works as expected now.
  • Options
    Still having trouble syncing data. This time it is a foreign key constraint. Here is the error:

    Error : The constraint 'PK__TABLE1__2E31B632' is being referenced by table 'TABLE2', foreign key constraint 'FK_TABLE2_TABLE1'.
    Could not drop constraint. See previous errors.
    DBSqlOptions.DropConstraintsAndIndexes| DBSqlOptions.DisableKeys|DBSqlOptions.ReseedIdentity|DBSqlOptions.UseTransactions

    I have set the provider.Options = session.Options. It is only syncing TABLE1, TABLE2 records are already identical.

Sign In or Register to comment.