diff --git a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs index 3d35c5d9eef..655e755a1e6 100644 --- a/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs +++ b/src/EFCore.SqlServer/Design/Internal/SqlServerAnnotationCodeGenerator.cs @@ -23,9 +23,9 @@ private static readonly MethodInfo ModelUseHiLoMethodInfo = typeof(SqlServerModelBuilderExtensions).GetRuntimeMethod( nameof(SqlServerModelBuilderExtensions.UseHiLo), new[] { typeof(ModelBuilder), typeof(string), typeof(string) })!; - private static readonly MethodInfo ModelUseKeySequenceMethodInfo + private static readonly MethodInfo ModelUseKeySequencesMethodInfo = typeof(SqlServerModelBuilderExtensions).GetRuntimeMethod( - nameof(SqlServerModelBuilderExtensions.UseKeySequence), new[] { typeof(ModelBuilder), typeof(string), typeof(string) })!; + nameof(SqlServerModelBuilderExtensions.UseKeySequences), new[] { typeof(ModelBuilder), typeof(string), typeof(string) })!; private static readonly MethodInfo ModelHasDatabaseMaxSizeMethodInfo = typeof(SqlServerModelBuilderExtensions).GetRuntimeMethod( @@ -63,9 +63,9 @@ private static readonly MethodInfo PropertyUseHiLoMethodInfo = typeof(SqlServerPropertyBuilderExtensions).GetRuntimeMethod( nameof(SqlServerPropertyBuilderExtensions.UseHiLo), new[] { typeof(PropertyBuilder), typeof(string), typeof(string) })!; - private static readonly MethodInfo PropertyUseKeySequenceMethodInfo + private static readonly MethodInfo PropertyUseSequenceMethodInfo = typeof(SqlServerPropertyBuilderExtensions).GetRuntimeMethod( - nameof(SqlServerPropertyBuilderExtensions.UseKeySequence), new[] { typeof(PropertyBuilder), typeof(string), typeof(string) })!; + nameof(SqlServerPropertyBuilderExtensions.UseSequence), new[] { typeof(PropertyBuilder), typeof(string), typeof(string) })!; private static readonly MethodInfo IndexIsClusteredMethodInfo = typeof(SqlServerIndexBuilderExtensions).GetRuntimeMethod( @@ -404,7 +404,7 @@ protected override bool IsHandledByConvention(IModel model, IAnnotation annotati var name = GetAndRemove(annotations, SqlServerAnnotationNames.KeySequenceName); var schema = GetAndRemove(annotations, SqlServerAnnotationNames.KeySequenceSchema); return new MethodCallCodeFragment( - onModel ? ModelUseKeySequenceMethodInfo : PropertyUseKeySequenceMethodInfo, + onModel ? ModelUseKeySequencesMethodInfo : PropertyUseSequenceMethodInfo, (name, schema) switch { (null, null) => Array.Empty(), diff --git a/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs index b99c01a5183..cab521f215d 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerModelBuilderExtensions.cs @@ -127,7 +127,7 @@ public static bool CanSetHiLoSequence( /// The name of the sequence. /// The schema of the sequence. /// The same builder instance so that multiple calls can be chained. - public static ModelBuilder UseKeySequence( + public static ModelBuilder UseKeySequences( this ModelBuilder modelBuilder, string? name = null, string? schema = null) @@ -141,7 +141,7 @@ public static ModelBuilder UseKeySequence( if (model.FindSequence(name, schema) == null) { - modelBuilder.HasSequence(name, schema).IncrementsBy(1); + modelBuilder.HasSequence(name, schema); } model.SetValueGenerationStrategy(SqlServerValueGenerationStrategy.Sequence); @@ -169,13 +169,13 @@ public static ModelBuilder UseKeySequence( /// The schema of the sequence. /// Indicates whether the configuration was specified using a data annotation. /// A builder to further configure the sequence. - public static IConventionSequenceBuilder? HasKeySequence( + public static IConventionSequenceBuilder? HasKeySequences( this IConventionModelBuilder modelBuilder, string? name, string? schema, bool fromDataAnnotation = false) { - if (!modelBuilder.CanSetSequence(name, schema)) + if (!modelBuilder.CanSetKeySequences(name, schema)) { return null; } @@ -199,7 +199,7 @@ public static ModelBuilder UseKeySequence( /// The schema of the sequence. /// Indicates whether the configuration was specified using a data annotation. /// if the given name and schema can be set for the hi-lo sequence. - public static bool CanSetSequence( + public static bool CanSetKeySequences( this IConventionModelBuilder modelBuilder, string? name, string? schema, @@ -386,13 +386,13 @@ public static bool CanSetIdentityColumnIncrement( { modelBuilder.HasIdentityColumnSeed(null, fromDataAnnotation); modelBuilder.HasIdentityColumnIncrement(null, fromDataAnnotation); - modelBuilder.HasKeySequence(null, null, fromDataAnnotation); + modelBuilder.HasKeySequences(null, null, fromDataAnnotation); } if (valueGenerationStrategy != SqlServerValueGenerationStrategy.SequenceHiLo) { modelBuilder.HasHiLoSequence(null, null, fromDataAnnotation); - modelBuilder.HasKeySequence(null, null, fromDataAnnotation); + modelBuilder.HasKeySequences(null, null, fromDataAnnotation); } if (valueGenerationStrategy != SqlServerValueGenerationStrategy.Sequence) diff --git a/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs index abbf7907c8b..2211a6bb262 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerModelExtensions.cs @@ -173,7 +173,7 @@ public static void SetKeySequenceName(this IMutableModel model, string? name) /// /// Returns the schema to use for the default hi-lo sequence. - /// + /// /// /// The model. /// The schema to use for the default key value generation sequence. diff --git a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs index faf9158cd38..bfa03d43646 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerPropertyBuilderExtensions.cs @@ -149,7 +149,7 @@ public static bool CanSetHiLoSequence( /// The name of the sequence. /// The schema of the sequence. /// The same builder instance so that multiple calls can be chained. - public static PropertyBuilder UseKeySequence( + public static PropertyBuilder UseSequence( this PropertyBuilder propertyBuilder, string? name = null, string? schema = null) @@ -169,8 +169,8 @@ public static PropertyBuilder UseKeySequence( } property.SetValueGenerationStrategy(SqlServerValueGenerationStrategy.Sequence); - property.SetKeySequenceName(name); - property.SetKeySequenceSchema(schema); + property.SetSequenceName(name); + property.SetSequenceSchema(schema); property.SetHiLoSequenceName(null); property.SetHiLoSequenceSchema(null); property.SetIdentitySeed(null); @@ -193,11 +193,11 @@ public static PropertyBuilder UseKeySequence( /// The name of the sequence. /// The schema of the sequence. /// The same builder instance so that multiple calls can be chained. - public static PropertyBuilder UseKeySequence( + public static PropertyBuilder UseSequence( this PropertyBuilder propertyBuilder, string? name = null, string? schema = null) - => (PropertyBuilder)UseKeySequence((PropertyBuilder)propertyBuilder, name, schema); + => (PropertyBuilder)UseSequence((PropertyBuilder)propertyBuilder, name, schema); /// /// Configures the database sequence used for the key value generation pattern to generate values for the key property, @@ -213,19 +213,19 @@ public static PropertyBuilder UseKeySequence( /// The schema of the sequence. /// Indicates whether the configuration was specified using a data annotation. /// A builder to further configure the sequence. - public static IConventionSequenceBuilder? HasKeySequence( + public static IConventionSequenceBuilder? HasSequence( this IConventionPropertyBuilder propertyBuilder, string? name, string? schema, bool fromDataAnnotation = false) { - if (!propertyBuilder.CanSetKeySequence(name, schema, fromDataAnnotation)) + if (!propertyBuilder.CanSetSequence(name, schema, fromDataAnnotation)) { return null; } - propertyBuilder.Metadata.SetKeySequenceName(name, fromDataAnnotation); - propertyBuilder.Metadata.SetKeySequenceSchema(schema, fromDataAnnotation); + propertyBuilder.Metadata.SetSequenceName(name, fromDataAnnotation); + propertyBuilder.Metadata.SetSequenceSchema(schema, fromDataAnnotation); return name == null ? null @@ -245,7 +245,7 @@ public static PropertyBuilder UseKeySequence( /// The schema of the sequence. /// Indicates whether the configuration was specified using a data annotation. /// if the given name and schema can be set for the key value generation sequence. - public static bool CanSetKeySequence( + public static bool CanSetSequence( this IConventionPropertyBuilder propertyBuilder, string? name, string? schema, @@ -282,8 +282,8 @@ public static PropertyBuilder UseIdentityColumn( property.SetIdentityIncrement(increment); property.SetHiLoSequenceName(null); property.SetHiLoSequenceSchema(null); - property.SetKeySequenceName(null); - property.SetKeySequenceSchema(null); + property.SetSequenceName(null); + property.SetSequenceSchema(null); return propertyBuilder; } @@ -629,13 +629,13 @@ public static bool CanSetIdentityColumnIncrement( { propertyBuilder.HasIdentityColumnSeed(null, fromDataAnnotation); propertyBuilder.HasIdentityColumnIncrement(null, fromDataAnnotation); - propertyBuilder.HasKeySequence(null, null, fromDataAnnotation); + propertyBuilder.HasSequence(null, null, fromDataAnnotation); } if (valueGenerationStrategy != SqlServerValueGenerationStrategy.SequenceHiLo) { propertyBuilder.HasHiLoSequence(null, null, fromDataAnnotation); - propertyBuilder.HasKeySequence(null, null, fromDataAnnotation); + propertyBuilder.HasSequence(null, null, fromDataAnnotation); } if (valueGenerationStrategy != SqlServerValueGenerationStrategy.Sequence) diff --git a/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs b/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs index 339c5e49e7b..75d095c83bb 100644 --- a/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs +++ b/src/EFCore.SqlServer/Extensions/SqlServerPropertyExtensions.cs @@ -202,7 +202,7 @@ public static void SetHiLoSequenceSchema(this IMutableProperty property, string? /// /// The property. /// The name to use for the key value generation sequence. - public static string? GetKeySequenceName(this IReadOnlyProperty property) + public static string? GetSequenceName(this IReadOnlyProperty property) => (string?)property[SqlServerAnnotationNames.KeySequenceName]; /// @@ -211,7 +211,7 @@ public static void SetHiLoSequenceSchema(this IMutableProperty property, string? /// The property. /// The identifier of the store object. /// The name to use for the key value generation sequence. - public static string? GetKeySequenceName(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject) + public static string? GetSequenceName(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject) { var annotation = property.FindAnnotation(SqlServerAnnotationNames.KeySequenceName); if (annotation != null) @@ -219,7 +219,7 @@ public static void SetHiLoSequenceSchema(this IMutableProperty property, string? return (string?)annotation.Value; } - return property.FindSharedStoreObjectRootProperty(storeObject)?.GetKeySequenceName(storeObject); + return property.FindSharedStoreObjectRootProperty(storeObject)?.GetSequenceName(storeObject); } /// @@ -227,7 +227,7 @@ public static void SetHiLoSequenceSchema(this IMutableProperty property, string? /// /// The property. /// The sequence name to use. - public static void SetKeySequenceName(this IMutableProperty property, string? name) + public static void SetSequenceName(this IMutableProperty property, string? name) => property.SetOrRemoveAnnotation( SqlServerAnnotationNames.KeySequenceName, Check.NullButNotEmpty(name, nameof(name))); @@ -239,7 +239,7 @@ public static void SetKeySequenceName(this IMutableProperty property, string? na /// The sequence name to use. /// Indicates whether the configuration was specified using a data annotation. /// The configured value. - public static string? SetKeySequenceName( + public static string? SetSequenceName( this IConventionProperty property, string? name, bool fromDataAnnotation = false) @@ -257,7 +257,7 @@ public static void SetKeySequenceName(this IMutableProperty property, string? na /// /// The property. /// The for the key value generation sequence name. - public static ConfigurationSource? GetKeySequenceNameConfigurationSource(this IConventionProperty property) + public static ConfigurationSource? GetSequenceNameConfigurationSource(this IConventionProperty property) => property.FindAnnotation(SqlServerAnnotationNames.KeySequenceName)?.GetConfigurationSource(); /// @@ -265,7 +265,7 @@ public static void SetKeySequenceName(this IMutableProperty property, string? na /// /// The property. /// The schema to use for the key value generation sequence. - public static string? GetKeySequenceSchema(this IReadOnlyProperty property) + public static string? GetSequenceSchema(this IReadOnlyProperty property) => (string?)property[SqlServerAnnotationNames.KeySequenceSchema]; /// @@ -274,7 +274,7 @@ public static void SetKeySequenceName(this IMutableProperty property, string? na /// The property. /// The identifier of the store object. /// The schema to use for the key value generation sequence. - public static string? GetKeySequenceSchema(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject) + public static string? GetSequenceSchema(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject) { var annotation = property.FindAnnotation(SqlServerAnnotationNames.KeySequenceSchema); if (annotation != null) @@ -282,7 +282,7 @@ public static void SetKeySequenceName(this IMutableProperty property, string? na return (string?)annotation.Value; } - return property.FindSharedStoreObjectRootProperty(storeObject)?.GetKeySequenceSchema(storeObject); + return property.FindSharedStoreObjectRootProperty(storeObject)?.GetSequenceSchema(storeObject); } /// @@ -290,7 +290,7 @@ public static void SetKeySequenceName(this IMutableProperty property, string? na /// /// The property. /// The schema to use. - public static void SetKeySequenceSchema(this IMutableProperty property, string? schema) + public static void SetSequenceSchema(this IMutableProperty property, string? schema) => property.SetOrRemoveAnnotation( SqlServerAnnotationNames.KeySequenceSchema, Check.NullButNotEmpty(schema, nameof(schema))); @@ -302,7 +302,7 @@ public static void SetKeySequenceSchema(this IMutableProperty property, string? /// The schema to use. /// Indicates whether the configuration was specified using a data annotation. /// The configured value. - public static string? SetKeySequenceSchema( + public static string? SetSequenceSchema( this IConventionProperty property, string? schema, bool fromDataAnnotation = false) @@ -320,7 +320,7 @@ public static void SetKeySequenceSchema(this IMutableProperty property, string? /// /// The property. /// The for the key value generation sequence schema. - public static ConfigurationSource? GetKeySequenceSchemaConfigurationSource(this IConventionProperty property) + public static ConfigurationSource? GetSequenceSchemaConfigurationSource(this IConventionProperty property) => property.FindAnnotation(SqlServerAnnotationNames.KeySequenceSchema)?.GetConfigurationSource(); /// @@ -328,14 +328,14 @@ public static void SetKeySequenceSchema(this IMutableProperty property, string? /// /// The property. /// The sequence to use, or if no sequence exists in the model. - public static IReadOnlySequence? FindKeySequence(this IReadOnlyProperty property) + public static IReadOnlySequence? FindSequence(this IReadOnlyProperty property) { var model = property.DeclaringEntityType.Model; - var sequenceName = property.GetKeySequenceName() + var sequenceName = property.GetSequenceName() ?? model.GetKeySequenceName(); - var sequenceSchema = property.GetKeySequenceSchema() + var sequenceSchema = property.GetSequenceSchema() ?? model.GetKeySequenceSchema(); return model.FindSequence(sequenceName, sequenceSchema); @@ -347,14 +347,14 @@ public static void SetKeySequenceSchema(this IMutableProperty property, string? /// The property. /// The identifier of the store object. /// The sequence to use, or if no sequence exists in the model. - public static IReadOnlySequence? FindKeySequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject) + public static IReadOnlySequence? FindSequence(this IReadOnlyProperty property, in StoreObjectIdentifier storeObject) { var model = property.DeclaringEntityType.Model; - var sequenceName = property.GetKeySequenceName(storeObject) + var sequenceName = property.GetSequenceName(storeObject) ?? model.GetKeySequenceName(); - var sequenceSchema = property.GetKeySequenceSchema(storeObject) + var sequenceSchema = property.GetSequenceSchema(storeObject) ?? model.GetKeySequenceSchema(); return model.FindSequence(sequenceName, sequenceSchema); @@ -365,8 +365,8 @@ public static void SetKeySequenceSchema(this IMutableProperty property, string? /// /// The property. /// The sequence to use, or if no sequence exists in the model. - public static ISequence? FindKeySequence(this IProperty property) - => (ISequence?)((IReadOnlyProperty)property).FindKeySequence(); + public static ISequence? FindSequence(this IProperty property) + => (ISequence?)((IReadOnlyProperty)property).FindSequence(); /// /// Finds the in the model to use for the key value generation pattern. @@ -374,8 +374,8 @@ public static void SetKeySequenceSchema(this IMutableProperty property, string? /// The property. /// The identifier of the store object. /// The sequence to use, or if no sequence exists in the model. - public static ISequence? FindKeySequence(this IProperty property, in StoreObjectIdentifier storeObject) - => (ISequence?)((IReadOnlyProperty)property).FindKeySequence(storeObject); + public static ISequence? FindSequence(this IProperty property, in StoreObjectIdentifier storeObject) + => (ISequence?)((IReadOnlyProperty)property).FindSequence(storeObject); /// /// Returns the identity seed. diff --git a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs index 74a7a1fe9e4..2fdf42e99de 100644 --- a/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs +++ b/src/EFCore.SqlServer/Metadata/Conventions/SqlServerValueGenerationStrategyConvention.cs @@ -59,7 +59,6 @@ public virtual void ProcessModelFinalizing( { SqlServerValueGenerationStrategy? strategy = null; var declaringTable = property.GetMappedStoreObjects(StoreObjectType.Table).FirstOrDefault(); - var declaringView = property.GetMappedStoreObjects(StoreObjectType.View).FirstOrDefault(); if (declaringTable.Name != null!) { strategy = property.GetValueGenerationStrategy(declaringTable, Dependencies.TypeMappingSource); @@ -71,6 +70,7 @@ public virtual void ProcessModelFinalizing( } else { + var declaringView = property.GetMappedStoreObjects(StoreObjectType.View).FirstOrDefault(); if (declaringView.Name != null!) { strategy = property.GetValueGenerationStrategy(declaringView, Dependencies.TypeMappingSource); @@ -83,13 +83,14 @@ public virtual void ProcessModelFinalizing( } // Needed for the annotation to show up in the model snapshot - if (strategy != null) + if (strategy != null + && declaringTable.Name != null) { property.Builder.HasValueGenerationStrategy(strategy); if (strategy == SqlServerValueGenerationStrategy.Sequence) { - var sequence = property.FindKeySequence(declaringTable.Name != null ? declaringTable : declaringView)!; + var sequence = property.FindSequence(declaringTable)!; property.Builder.HasDefaultValueSql( RelationalDependencies.UpdateSqlGenerator.GenerateObtainNextSequenceValueOperation( diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs index 0f3642030ea..ff002ef928a 100644 --- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs @@ -382,7 +382,7 @@ public virtual void Model_fluent_APIs_for_sequence_key_are_properly_generated() => Test( builder => { - builder.UseKeySequence(); + builder.UseKeySequences(); builder.Entity(); builder.Ignore(); }, @@ -390,7 +390,7 @@ public virtual void Model_fluent_APIs_for_sequence_key_are_properly_generated() @" modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); - SqlServerModelBuilderExtensions.UseKeySequence(modelBuilder, ""EntityFrameworkKeySequence""); + SqlServerModelBuilderExtensions.UseKeySequences(modelBuilder, ""EntityFrameworkKeySequence""); modelBuilder.HasSequence(""EntityFrameworkKeySequence""); @@ -401,7 +401,7 @@ public virtual void Model_fluent_APIs_for_sequence_key_are_properly_generated() .HasColumnType(""int"") .HasDefaultValueSql(""NEXT VALUE FOR [EntityFrameworkKeySequence]""); - SqlServerPropertyBuilderExtensions.UseKeySequence(b.Property(""Id"")); + SqlServerPropertyBuilderExtensions.UseSequence(b.Property(""Id"")); b.HasKey(""Id""); diff --git a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs index a5a293887c8..96e284e5eda 100644 --- a/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs +++ b/test/EFCore.Design.Tests/Scaffolding/Internal/CSharpRuntimeModelCodeGeneratorTest.cs @@ -3847,7 +3847,7 @@ public static void CreateAnnotations(RuntimeEntityType runtimeEntityType) Assert.Single((IEnumerable)model.GetEntityTypes()); var dataEntity = model.FindEntityType(typeof(Data)); - Assert.Same(keySequence, dataEntity!.FindPrimaryKey().Properties.Single().FindKeySequence()); + Assert.Same(keySequence, dataEntity!.FindPrimaryKey().Properties.Single().FindSequence()); }); public class KeySequencesContext : SqlServerContextBase @@ -3859,7 +3859,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) modelBuilder.Entity( eb => { - eb.Property("Id").UseKeySequence("KeySeq", "KeySeqSchema"); + eb.Property("Id").UseSequence("KeySeq", "KeySeqSchema"); eb.HasKey("Id"); }); } diff --git a/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs b/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs index 81561149004..a1a210cdd49 100644 --- a/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs +++ b/test/EFCore.Specification.Tests/Query/InheritanceQueryFixtureBase.cs @@ -28,7 +28,9 @@ public Func GetContextCreator() => () => CreateContext(); public virtual ISetSource GetExpectedData() - => new InheritanceData(UseGeneratedKeys); + => UseGeneratedKeys + ? InheritanceData.GeneratedKeysInstance + : InheritanceData.Instance; public virtual ISetSource GetFilteredExpectedData(DbContext context) { @@ -66,10 +68,10 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) { typeof(Daisy), e => ((Daisy)e)?.Species }, { typeof(Rose), e => ((Rose)e)?.Species }, { typeof(Country), e => ((Country)e)?.Id }, - { typeof(Drink), e => ((Drink)e)?.Id }, - { typeof(Coke), e => ((Coke)e)?.Id }, - { typeof(Lilt), e => ((Lilt)e)?.Id }, - { typeof(Tea), e => ((Tea)e)?.Id }, + { typeof(Drink), e => ((Drink)e)?.SortIndex }, + { typeof(Coke), e => ((Coke)e)?.SortIndex }, + { typeof(Lilt), e => ((Lilt)e)?.SortIndex }, + { typeof(Tea), e => ((Tea)e)?.SortIndex }, }.ToDictionary(e => e.Key, e => (object)e.Value); public IReadOnlyDictionary EntityAsserters { get; } = new Dictionary> @@ -104,7 +106,6 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) Assert.Equal(ee.Name, aa.Name); Assert.Equal(ee.CountryId, aa.CountryId); Assert.Equal(ee.IsFlightless, aa.IsFlightless); - Assert.Equal(ee.EagleId, aa.EagleId); } } }, @@ -122,7 +123,6 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) Assert.Equal(ee.Name, aa.Name); Assert.Equal(ee.CountryId, aa.CountryId); Assert.Equal(ee.IsFlightless, aa.IsFlightless); - Assert.Equal(ee.EagleId, aa.EagleId); Assert.Equal(ee.Group, aa.Group); } } @@ -141,7 +141,6 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) Assert.Equal(ee.Name, aa.Name); Assert.Equal(ee.CountryId, aa.CountryId); Assert.Equal(ee.IsFlightless, aa.IsFlightless); - Assert.Equal(ee.EagleId, aa.EagleId); Assert.Equal(ee.FoundOn, aa.FoundOn); } } @@ -304,7 +303,7 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) var ee = (Drink)e; var aa = (Drink)a; - Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.SortIndex, aa.SortIndex); } } }, @@ -318,7 +317,7 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) var ee = (Coke)e; var aa = (Coke)a; - Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.SortIndex, aa.SortIndex); Assert.Equal(ee.SugarGrams, aa.SugarGrams); Assert.Equal(ee.CaffeineGrams, aa.CaffeineGrams); Assert.Equal(ee.Carbonation, aa.Carbonation); @@ -335,7 +334,7 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) var ee = (Lilt)e; var aa = (Lilt)a; - Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.SortIndex, aa.SortIndex); Assert.Equal(ee.SugarGrams, aa.SugarGrams); Assert.Equal(ee.Carbonation, aa.Carbonation); } @@ -351,7 +350,7 @@ public virtual ISetSource GetFilteredExpectedData(DbContext context) var ee = (Tea)e; var aa = (Tea)a; - Assert.Equal(ee.Id, aa.Id); + Assert.Equal(ee.SortIndex, aa.SortIndex); Assert.Equal(ee.HasMilk, aa.HasMilk); Assert.Equal(ee.CaffeineGrams, aa.CaffeineGrams); } diff --git a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs index 8613350133b..b2548ca0c42 100644 --- a/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs +++ b/test/EFCore.Specification.Tests/TestModels/InheritanceModel/InheritanceData.cs @@ -5,7 +5,8 @@ namespace Microsoft.EntityFrameworkCore.TestModels.InheritanceModel; public class InheritanceData : ISetSource { - public static readonly InheritanceData Instance = new(); + public static readonly InheritanceData Instance = new(useGeneratedKeys: false); + public static readonly InheritanceData GeneratedKeysInstance = new(useGeneratedKeys: true); public IReadOnlyList Animals { get; } public IReadOnlyList AnimalQueries { get; } @@ -13,7 +14,7 @@ public class InheritanceData : ISetSource public IReadOnlyList Drinks { get; } public IReadOnlyList Plants { get; } - private InheritanceData() + public InheritanceData(bool useGeneratedKeys) { Animals = CreateAnimals(useGeneratedKeys); Countries = CreateCountries(); diff --git a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs index 01ca1a282a4..63fa1078c96 100644 --- a/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/GraphUpdates/GraphUpdatesSqlServerSequenceTest.cs @@ -20,7 +20,7 @@ protected override string StoreName protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); base.OnModelCreating(modelBuilder, context); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCFiltersInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCFiltersInheritanceQuerySqlServerFixture.cs index eef5acc09e1..29b31310679 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCFiltersInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCFiltersInheritanceQuerySqlServerFixture.cs @@ -10,7 +10,7 @@ protected override bool EnableFilters protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); base.OnModelCreating(modelBuilder, context); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs index c594a410f2b..0edd497f9f5 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPCInheritanceQuerySqlServerFixture.cs @@ -10,7 +10,7 @@ protected override ITestStoreFactory TestStoreFactory protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); base.OnModelCreating(modelBuilder, context); } diff --git a/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs b/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs index 72319a92be9..745a28677d3 100644 --- a/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs +++ b/test/EFCore.SqlServer.FunctionalTests/Query/TPTInheritanceQuerySqlServerFixture.cs @@ -10,7 +10,7 @@ protected override ITestStoreFactory TestStoreFactory protected override void OnModelCreating(ModelBuilder modelBuilder, DbContext context) { - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); base.OnModelCreating(modelBuilder, context); } diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs index 1e55487018e..21cc19a0a5c 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationConflictTest.cs @@ -42,7 +42,7 @@ public virtual void SqlServerValueGeneration_conflicting_with_existing_default_v modelBuilder.Entity() .Property(e => e.Id) .HasDefaultValueSql("2") - .UseKeySequence(); + .UseSequence(); Assert.Equal( CoreStrings.WarningAsErrorTemplate( diff --git a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs index 30773f1d940..2f646fc733b 100644 --- a/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs +++ b/test/EFCore.SqlServer.FunctionalTests/SqlServerValueGenerationScenariosTest.cs @@ -131,7 +131,7 @@ protected override void OnModelCreating(ModelBuilder modelBuilder) { base.OnModelCreating(modelBuilder); - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); modelBuilder.Entity( eb => diff --git a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs index ca48e38022b..bf2e5913dfe 100644 --- a/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs +++ b/test/EFCore.SqlServer.Tests/Design/Internal/SqlServerAnnotationCodeGeneratorTest.cs @@ -252,12 +252,12 @@ public void GenerateFluentApi_IModel_works_with_KeySequence() { var generator = CreateGenerator(); var modelBuilder = SqlServerConventionSetBuilder.CreateModelBuilder(); - modelBuilder.UseKeySequence("KeySequenceName", "KeySequenceSchema"); + modelBuilder.UseKeySequences("KeySequenceName", "KeySequenceSchema"); var annotations = modelBuilder.Model.GetAnnotations().ToDictionary(a => a.Name, a => a); var result = generator.GenerateFluentApiCalls((IModel)modelBuilder.Model, annotations).Single(); - Assert.Equal("UseKeySequence", result.Method); + Assert.Equal("UseKeySequences", result.Method); Assert.Equal("SqlServerModelBuilderExtensions", result.DeclaringType); Assert.Collection( @@ -271,13 +271,13 @@ public void GenerateFluentApi_IProperty_works_with_KeySequence() { var generator = CreateGenerator(); var modelBuilder = SqlServerConventionSetBuilder.CreateModelBuilder(); - modelBuilder.Entity("Post", x => x.Property("Id").UseKeySequence("KeySequenceName", "KeySequenceSchema")); + modelBuilder.Entity("Post", x => x.Property("Id").UseSequence("KeySequenceName", "KeySequenceSchema")); var property = modelBuilder.Model.FindEntityType("Post")!.FindProperty("Id")!; var annotations = property.GetAnnotations().ToDictionary(a => a.Name, a => a); var result = generator.GenerateFluentApiCalls((IProperty)property, annotations).Single(); - Assert.Equal("UseKeySequence", result.Method); + Assert.Equal("UseSequence", result.Method); Assert.Equal("SqlServerPropertyBuilderExtensions", result.DeclaringType); Assert.Collection( diff --git a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs index 081d3d34dd8..123839bcb23 100644 --- a/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs +++ b/test/EFCore.SqlServer.Tests/Infrastructure/SqlServerModelValidatorTest.cs @@ -203,13 +203,13 @@ public virtual void Passes_for_duplicate_column_names_with_KeySequence() cb => { cb.ToTable("Animal"); - cb.Property(c => c.Id).UseKeySequence(); + cb.Property(c => c.Id).UseSequence(); }); modelBuilder.Entity( db => { db.ToTable("Animal"); - db.Property(d => d.Id).UseKeySequence(); + db.Property(d => d.Id).UseSequence(); db.HasOne().WithOne().HasForeignKey(d => d.Id); }); @@ -224,13 +224,13 @@ public virtual void Detects_duplicate_column_names_with_different_KeySequence_na cb => { cb.ToTable("Animal"); - cb.Property(c => c.Id).UseKeySequence("foo"); + cb.Property(c => c.Id).UseSequence("foo"); }); modelBuilder.Entity( db => { db.ToTable("Animal"); - db.Property(d => d.Id).UseKeySequence(); + db.Property(d => d.Id).UseSequence(); db.HasOne().WithOne().HasForeignKey(d => d.Id); }); @@ -250,13 +250,13 @@ public virtual void Detects_duplicate_column_name_with_different_KeySequence_sch cb => { cb.ToTable("Animal"); - cb.Property(c => c.Id).UseKeySequence("foo", "dbo"); + cb.Property(c => c.Id).UseSequence("foo", "dbo"); }); modelBuilder.Entity( db => { db.ToTable("Animal"); - db.Property(d => d.Id).UseKeySequence("foo", "dba"); + db.Property(d => d.Id).UseSequence("foo", "dba"); db.HasOne().WithOne().HasForeignKey(d => d.Id); }); @@ -632,7 +632,7 @@ public void Passes_for_non_key_SequenceHiLo_on_model() public void Detects_non_key_KeySequence() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.Entity().Property(c => c.Type).UseKeySequence(); + modelBuilder.Entity().Property(c => c.Type).UseSequence(); VerifyError(SqlServerStrings.NonKeyValueGeneration(nameof(Dog.Type), nameof(Dog)), modelBuilder); } @@ -642,7 +642,7 @@ public void Passes_for_non_key_KeySequence_on_model() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); modelBuilder.Entity().Property(c => c.Type).ValueGeneratedOnAdd(); diff --git a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerValueGenerationStrategyConventionTest.cs b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerValueGenerationStrategyConventionTest.cs index d5a9f8b70f8..1602f2ff1a2 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerValueGenerationStrategyConventionTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/Conventions/SqlServerValueGenerationStrategyConventionTest.cs @@ -52,7 +52,7 @@ public void Annotations_are_added_when_conventional_model_builder_is_used_with_s public void Annotations_are_added_when_conventional_model_builder_is_used_with_key_sequences() { var model = SqlServerTestHelpers.Instance.CreateConventionBuilder() - .UseKeySequence() + .UseKeySequences() .Model; model.RemoveAnnotation(CoreAnnotationNames.ProductVersion); diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs index e199111880f..971c4735205 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerBuilderExtensionsTest.cs @@ -364,7 +364,7 @@ public void Can_set_key_sequences_for_model() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.UseKeySequence(); + modelBuilder.UseKeySequences(); var relationalExtensions = modelBuilder.Model; var sqlServerExtensions = modelBuilder.Model; @@ -382,7 +382,7 @@ public void Can_set_key_sequences_with_name_for_model() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.UseKeySequence("Snook"); + modelBuilder.UseKeySequences("Snook"); var relationalExtensions = modelBuilder.Model; var sqlServerExtensions = modelBuilder.Model; @@ -409,7 +409,7 @@ public void Can_set_key_sequences_with_schema_and_name_for_model() { var modelBuilder = CreateConventionModelBuilder(); - modelBuilder.UseKeySequence("Snook", "Tasty"); + modelBuilder.UseKeySequences("Snook", "Tasty"); var relationalExtensions = modelBuilder.Model; var sqlServerExtensions = modelBuilder.Model; @@ -442,7 +442,7 @@ public void Can_set_use_of_existing_relational_key_sequence_for_model() .HasMin(111) .HasMax(2222); - modelBuilder.UseKeySequence("Snook", "Tasty"); + modelBuilder.UseKeySequences("Snook", "Tasty"); var relationalExtensions = modelBuilder.Model; var sqlServerExtensions = modelBuilder.Model; @@ -467,7 +467,7 @@ public void Can_set_use_of_existing_SQL_key_sequence_for_model() .HasMin(111) .HasMax(2222); - modelBuilder.UseKeySequence("Snook", "Tasty"); + modelBuilder.UseKeySequences("Snook", "Tasty"); var relationalExtensions = modelBuilder.Model; var sqlServerExtensions = modelBuilder.Model; @@ -744,14 +744,14 @@ public void Can_set_key_sequence_for_property() modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence(); + .UseSequence(); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal(SqlServerModelExtensions.DefaultKeySequenceName, property.GetKeySequenceName()); + Assert.Equal(SqlServerModelExtensions.DefaultKeySequenceName, property.GetSequenceName()); Assert.NotNull(model.FindSequence(SqlServerModelExtensions.DefaultKeySequenceName)); Assert.NotNull(model.FindSequence(SqlServerModelExtensions.DefaultKeySequenceName)); @@ -765,15 +765,15 @@ public void Can_set_key_sequences_with_name_for_property() modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence("Snook"); + .UseSequence("Snook"); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal("Snook", property.GetKeySequenceName()); - Assert.Null(property.GetKeySequenceSchema()); + Assert.Equal("Snook", property.GetSequenceName()); + Assert.Null(property.GetSequenceSchema()); Assert.NotNull(model.FindSequence("Snook")); @@ -796,15 +796,15 @@ public void Can_set_key_sequences_with_schema_and_name_for_property() modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence("Snook", "Tasty"); + .UseSequence("Snook", "Tasty"); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal("Snook", property.GetKeySequenceName()); - Assert.Equal("Tasty", property.GetKeySequenceSchema()); + Assert.Equal("Snook", property.GetSequenceName()); + Assert.Equal("Tasty", property.GetSequenceSchema()); Assert.NotNull(model.FindSequence("Snook", "Tasty")); @@ -833,15 +833,15 @@ public void Can_set_use_of_existing_relational_key_sequence_for_property() modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence("Snook", "Tasty"); + .UseSequence("Snook", "Tasty"); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal("Snook", property.GetKeySequenceName()); - Assert.Equal("Tasty", property.GetKeySequenceSchema()); + Assert.Equal("Snook", property.GetSequenceName()); + Assert.Equal("Tasty", property.GetSequenceSchema()); ValidateSchemaNamedSpecificSequence(model.FindSequence("Snook", "Tasty")); ValidateSchemaNamedSpecificSequence(model.FindSequence("Snook", "Tasty")); @@ -856,15 +856,15 @@ public void Can_set_use_of_existing_relational_key_sequence_for_property_using_n .HasSequence("Snook", "Tasty", b => b.IncrementsBy(11).StartsAt(1729).HasMin(111).HasMax(2222)) .Entity() .Property(e => e.Id) - .UseKeySequence("Snook", "Tasty"); + .UseSequence("Snook", "Tasty"); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal("Snook", property.GetKeySequenceName()); - Assert.Equal("Tasty", property.GetKeySequenceSchema()); + Assert.Equal("Snook", property.GetSequenceName()); + Assert.Equal("Tasty", property.GetSequenceSchema()); ValidateSchemaNamedSpecificSequence(model.FindSequence("Snook", "Tasty")); ValidateSchemaNamedSpecificSequence(model.FindSequence("Snook", "Tasty")); @@ -885,15 +885,15 @@ public void Can_set_use_of_existing_SQL_key_sequence_for_property() modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence("Snook", "Tasty"); + .UseSequence("Snook", "Tasty"); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal("Snook", property.GetKeySequenceName()); - Assert.Equal("Tasty", property.GetKeySequenceSchema()); + Assert.Equal("Snook", property.GetSequenceName()); + Assert.Equal("Tasty", property.GetSequenceSchema()); ValidateSchemaNamedSpecificSequence(model.FindSequence("Snook", "Tasty")); } @@ -916,15 +916,15 @@ public void Can_set_use_of_existing_SQL_key_sequence_for_property_using_nested_c modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence("Snook", "Tasty"); + .UseSequence("Snook", "Tasty"); var model = modelBuilder.Model; var property = model.FindEntityType(typeof(Customer)).FindProperty("Id"); Assert.Equal(SqlServerValueGenerationStrategy.Sequence, property.GetValueGenerationStrategy()); Assert.Equal(ValueGenerated.OnAdd, property.ValueGenerated); - Assert.Equal("Snook", property.GetKeySequenceName()); - Assert.Equal("Tasty", property.GetKeySequenceSchema()); + Assert.Equal("Snook", property.GetSequenceName()); + Assert.Equal("Tasty", property.GetSequenceSchema()); ValidateSchemaNamedSpecificSequence(model.FindSequence("Snook", "Tasty")); } @@ -1017,7 +1017,7 @@ public void SqlServer_property_methods_dont_break_out_of_the_generics() modelBuilder .Entity() .Property(e => e.Id) - .UseKeySequence()); + .UseSequence()); } [ConditionalFact] @@ -1038,7 +1038,7 @@ public void SqlServer_property_methods_have_non_generic_overloads() modelBuilder .Entity(typeof(Customer)) .Property(typeof(int), "Id") - .UseKeySequence(); + .UseSequence(); } [ConditionalFact] diff --git a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs index 4aab48b8cf2..efc8b0a4747 100644 --- a/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs +++ b/test/EFCore.SqlServer.Tests/Metadata/SqlServerMetadataBuilderExtensionsTest.cs @@ -197,7 +197,7 @@ public void Throws_setting_key_sequence_generation_for_invalid_type() Assert.Equal( SqlServerStrings.SequenceBadType("Name", nameof(Splot), "string"), Assert.Throws( - () => new PropertyBuilder((IMutableProperty)propertyBuilder.Metadata).UseKeySequence()).Message); + () => new PropertyBuilder((IMutableProperty)propertyBuilder.Metadata).UseSequence()).Message); } [ConditionalFact] diff --git a/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs b/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs index 1a7a0a327cc..70d642bf645 100644 --- a/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs +++ b/test/EFCore.SqlServer.Tests/Migrations/SqlServerModelDifferTest.cs @@ -452,7 +452,7 @@ public void Add_KeySequence_with_seed_data() x => { x.ToTable("Firefly", "dbo"); - x.Property("SequenceId").UseKeySequence(schema: "dbo"); + x.Property("SequenceId").UseSequence(schema: "dbo"); x.HasData( new { Id = 43 }); }), diff --git a/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs b/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs index fd159094955..da17db4b69f 100644 --- a/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs +++ b/test/EFCore.SqlServer.Tests/SqlServerValueGeneratorSelectorTest.cs @@ -47,7 +47,7 @@ private void AssertGenerator(string propertyName, bool useHiLo = fals if (useKeySequence) { - builder.UseKeySequence(); + builder.UseKeySequences(); Assert.NotNull(builder.Model.FindSequence(SqlServerModelExtensions.DefaultKeySequenceName)); }