Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change from sequence-per-model to sequence-per-hierarchy when using sequences for key generation #28501

Merged
merged 1 commit into from
Jul 25, 2022

Conversation

ajcvickers
Copy link
Contributor

Part of #28096

@ajcvickers ajcvickers requested a review from a team July 23, 2022 22:47
@@ -180,10 +175,10 @@ public static class SqlServerModelBuilderExtensions
return null;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this method and CanSetKeySequences, it doesn't seem very useful and the name doesn't really match the functionality

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AndriySvyryd In this code, should the KeySequences annotations be unconditionally set to null, regardless of configuration source?

public static IConventionModelBuilder? HasValueGenerationStrategy(
        this IConventionModelBuilder modelBuilder,
        SqlServerValueGenerationStrategy? valueGenerationStrategy,
        bool fromDataAnnotation = false)
    {
        if (modelBuilder.CanSetValueGenerationStrategy(valueGenerationStrategy, fromDataAnnotation))
        {
            modelBuilder.Metadata.SetValueGenerationStrategy(valueGenerationStrategy, fromDataAnnotation);
            if (valueGenerationStrategy != SqlServerValueGenerationStrategy.IdentityColumn)
            {
                modelBuilder.HasIdentityColumnSeed(null, fromDataAnnotation);
                modelBuilder.HasIdentityColumnIncrement(null, fromDataAnnotation);
                modelBuilder.HasKeySequences(null, null, fromDataAnnotation);
            }
            if (valueGenerationStrategy != SqlServerValueGenerationStrategy.SequenceHiLo)
            {
                modelBuilder.HasHiLoSequence(null, null, fromDataAnnotation);
                modelBuilder.HasKeySequences(null, null, fromDataAnnotation);
            }
            if (valueGenerationStrategy != SqlServerValueGenerationStrategy.Sequence)
            {
                modelBuilder.HasIdentityColumnSeed(null, fromDataAnnotation);
                modelBuilder.HasIdentityColumnIncrement(null, fromDataAnnotation);
                modelBuilder.HasHiLoSequence(null, null, fromDataAnnotation);
            }
            return modelBuilder;
        }
        return null;
    }

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, it should be changed to check the source

@ajcvickers ajcvickers merged commit e74fc5d into Sequencer0715 Jul 25, 2022
@ajcvickers ajcvickers deleted the Pants0723 branch July 25, 2022 19:59
ajcvickers added a commit that referenced this pull request Jul 26, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants