From 25ab6f97dbb5f574931b43c6c237a92e282e9285 Mon Sep 17 00:00:00 2001 From: Shay Rojansky Date: Mon, 11 Jan 2021 13:11:19 +0100 Subject: [PATCH] Don't generate Fluent API in model snapshot for certain annotations Temporary fix for 5.0. Fixes #23456 --- .../Design/CSharpSnapshotGenerator.cs | 52 +++- .../Migrations/ModelSnapshotSqlServerTest.cs | 291 ++++++++++-------- 2 files changed, 220 insertions(+), 123 deletions(-) diff --git a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs index 0c2e11616ee..8a2903667de 100644 --- a/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs +++ b/src/EFCore.Design/Migrations/Design/CSharpSnapshotGenerator.cs @@ -3,6 +3,7 @@ using System; using System.Collections.Generic; +using System.Collections.Immutable; using System.Linq; using JetBrains.Annotations; using Microsoft.EntityFrameworkCore.Design; @@ -64,6 +65,16 @@ public virtual void Generate(string builderName, IModel model, IndentedStringBui using (stringBuilder.Indent()) { + // Temporary patch: specifically exclude some annotations which are known to produce identical Fluent API calls across different + // providers, generating them as raw annotations instead. + var ambiguousAnnotations = RemoveAmbiguousFluentApiAnnotations( + annotations, + name => name.EndsWith(":ValueGenerationStrategy", StringComparison.Ordinal) + || name.EndsWith(":IdentityIncrement", StringComparison.Ordinal) + || name.EndsWith(":IdentitySeed", StringComparison.Ordinal) + || name.EndsWith(":HiLoSequenceName", StringComparison.Ordinal) + || name.EndsWith(":HiLoSequenceSchema", StringComparison.Ordinal)); + foreach (var methodCallCodeFragment in Dependencies.AnnotationCodeGenerator.GenerateFluentApiCalls(model, annotations)) { @@ -79,7 +90,7 @@ public virtual void Generate(string builderName, IModel model, IndentedStringBui new Annotation(CoreAnnotationNames.ProductVersion, productVersion)); } - GenerateAnnotations(remainingAnnotations, stringBuilder); + GenerateAnnotations(remainingAnnotations.Concat(ambiguousAnnotations), stringBuilder); } stringBuilder.AppendLine(";"); @@ -574,6 +585,16 @@ protected virtual void GeneratePropertyAnnotations([NotNull] IProperty property, GenerateFluentApiForDefaultValue(property, stringBuilder); annotations.Remove(RelationalAnnotationNames.DefaultValue); + // Temporary patch: specifically exclude some annotations which are known to produce identical Fluent API calls across different + // providers, generating them as raw annotations instead. + var ambiguousAnnotations = RemoveAmbiguousFluentApiAnnotations( + annotations, + name => name.EndsWith(":ValueGenerationStrategy", StringComparison.Ordinal) + || name.EndsWith(":IdentityIncrement", StringComparison.Ordinal) + || name.EndsWith(":IdentitySeed", StringComparison.Ordinal) + || name.EndsWith(":HiLoSequenceName", StringComparison.Ordinal) + || name.EndsWith(":HiLoSequenceSchema", StringComparison.Ordinal)); + foreach (var methodCallCodeFragment in Dependencies.AnnotationCodeGenerator.GenerateFluentApiCalls(property, annotations)) { @@ -582,7 +603,7 @@ protected virtual void GeneratePropertyAnnotations([NotNull] IProperty property, .Append(Code.Fragment(methodCallCodeFragment)); } - GenerateAnnotations(annotations.Values, stringBuilder); + GenerateAnnotations(annotations.Values.Concat(ambiguousAnnotations), stringBuilder); } private ValueConverter FindValueConverter(IProperty property) @@ -765,6 +786,12 @@ protected virtual void GenerateIndexAnnotations( .FilterIgnoredAnnotations(index.GetAnnotations()) .ToDictionary(a => a.Name, a => a); + // Temporary patch: specifically exclude some annotations which are known to produce identical Fluent API calls across different + // providers, generating them as raw annotations instead. + var ambiguousAnnotations = RemoveAmbiguousFluentApiAnnotations( + annotations, + name => name.EndsWith(":Include", StringComparison.Ordinal)); + foreach (var methodCallCodeFragment in Dependencies.AnnotationCodeGenerator.GenerateFluentApiCalls(index, annotations)) { @@ -773,7 +800,7 @@ protected virtual void GenerateIndexAnnotations( .Append(Code.Fragment(methodCallCodeFragment)); } - GenerateAnnotations(annotations.Values, stringBuilder); + GenerateAnnotations(annotations.Values.Concat(ambiguousAnnotations), stringBuilder); } /// @@ -1565,5 +1592,24 @@ private void GenerateFluentApiForDefaultValue( stringBuilder .Append(")"); } + + private static IReadOnlyList RemoveAmbiguousFluentApiAnnotations( + Dictionary annotations, + Func annotationNameMatcher) + { + List ambiguousAnnotations = null; + + foreach (var (name, annotation) in annotations) + { + if (annotationNameMatcher(name)) + { + annotations.Remove(name); + ambiguousAnnotations ??= new List(); + ambiguousAnnotations.Add(annotation); + } + } + + return (IReadOnlyList)ambiguousAnnotations ?? ImmutableList.Empty; + } } } diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs index 5b49e09d5a8..2f21ece065c 100644 --- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs @@ -295,15 +295,15 @@ public virtual void Model_annotations_are_stored_in_snapshot() AddBoilerPlate( @" modelBuilder - .UseIdentityColumns() .HasAnnotation(""AnnotationName"", ""AnnotationValue"") .HasAnnotation(""Relational:MaxIdentifierLength"", 128) .HasAnnotation(""SqlServer:DatabaseMaxSize"", ""100 MB"") .HasAnnotation(""SqlServer:PerformanceLevelSql"", ""'S0'"") - .HasAnnotation(""SqlServer:ServiceTierSql"", ""'basic'"");"), + .HasAnnotation(""SqlServer:ServiceTierSql"", ""'basic'"") + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);"), o => { - Assert.Equal(9, o.GetAnnotations().Count()); + Assert.Equal(7, o.GetAnnotations().Count()); Assert.Equal("AnnotationValue", o["AnnotationName"]); }); } @@ -321,12 +321,12 @@ public virtual void Model_default_schema_annotation_is_stored_in_snapshot_as_flu @" modelBuilder .HasDefaultSchema(""DefaultSchema"") - .UseIdentityColumns() .HasAnnotation(""AnnotationName"", ""AnnotationValue"") - .HasAnnotation(""Relational:MaxIdentifierLength"", 128);"), + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);"), o => { - Assert.Equal(7, o.GetAnnotations().Count()); + Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal("AnnotationValue", o["AnnotationName"]); Assert.Equal("DefaultSchema", o[RelationalAnnotationNames.DefaultSchema]); }); @@ -349,7 +349,7 @@ public virtual void Entities_are_stored_in_model_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -361,7 +361,7 @@ public virtual void Entities_are_stored_in_model_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -400,7 +400,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Discriminator"") .HasColumnType(""nvarchar(max)""); @@ -430,7 +430,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() });"), o => { - Assert.Equal(5, o.GetAnnotations().Count()); + Assert.Equal(3, o.GetAnnotations().Count()); Assert.Equal( "DerivedEntity", @@ -457,7 +457,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT_with_one_exclu b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Discriminator"") .HasColumnType(""nvarchar(max)""); @@ -487,7 +487,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT_with_one_exclu });"), o => { - Assert.Equal(5, o.GetAnnotations().Count()); + Assert.Equal(3, o.GetAnnotations().Count()); Assert.Equal( "DerivedEntity", @@ -508,7 +508,7 @@ public void Views_are_stored_in_the_model_snapshot() { b.Property(""Id"") .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -597,7 +597,7 @@ public virtual void Sequence_is_stored_in_snapshot_as_fluent_api() .IsCyclic();"), o => { - Assert.Equal(6, o.GetAnnotations().Count()); + Assert.Equal(4, o.GetAnnotations().Count()); }); } @@ -619,7 +619,7 @@ public virtual void CheckConstraint_is_stored_in_snapshot_as_fluent_api() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -632,7 +632,7 @@ public virtual void CheckConstraint_is_stored_in_snapshot_as_fluent_api() });"), o => { - Assert.Equal(5, o.GetAnnotations().Count()); + Assert.Equal(3, o.GetAnnotations().Count()); }); } @@ -654,7 +654,7 @@ public virtual void CheckConstraint_is_only_stored_in_snapshot_once_for_TPH() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Discriminator"") .IsRequired() @@ -680,7 +680,7 @@ public virtual void CheckConstraint_is_only_stored_in_snapshot_once_for_TPH() });"), o => { - Assert.Equal(5, o.GetAnnotations().Count()); + Assert.Equal(3, o.GetAnnotations().Count()); }); } @@ -704,8 +704,10 @@ public virtual void Model_use_identity_columns() AddBoilerPlate( @" modelBuilder - .UseIdentityColumns() - .HasAnnotation(""Relational:MaxIdentifierLength"", 128);"), + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:IdentityIncrement"", 1) + .HasAnnotation(""SqlServer:IdentitySeed"", 1) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);"), o => { Assert.Equal(5, o.GetAnnotations().Count()); @@ -723,8 +725,10 @@ public virtual void Model_use_identity_columns_custom_seed() AddBoilerPlate( @" modelBuilder - .UseIdentityColumns(5) - .HasAnnotation(""Relational:MaxIdentifierLength"", 128);"), + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:IdentityIncrement"", 1) + .HasAnnotation(""SqlServer:IdentitySeed"", 5) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);"), o => { Assert.Equal(5, o.GetAnnotations().Count()); @@ -742,9 +746,11 @@ public virtual void Model_use_identity_columns_custom_increment() AddBoilerPlate( @" modelBuilder - .UseIdentityColumns(1, 5) - .HasAnnotation(""Relational:MaxIdentifierLength"", 128);"), - o => + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:IdentityIncrement"", 5) + .HasAnnotation(""SqlServer:IdentitySeed"", 1) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);"), + o => { Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, o.GetValueGenerationStrategy()); @@ -761,8 +767,10 @@ public virtual void Model_use_identity_columns_custom_seed_increment() AddBoilerPlate( @" modelBuilder - .UseIdentityColumns(5, 5) - .HasAnnotation(""Relational:MaxIdentifierLength"", 128);"), + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:IdentityIncrement"", 5) + .HasAnnotation(""SqlServer:IdentitySeed"", 5) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);"), o => { Assert.Equal(5, o.GetAnnotations().Count()); @@ -793,7 +801,7 @@ public virtual void EntityType_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -826,7 +834,7 @@ public virtual void BaseType_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Discriminator"") .IsRequired() @@ -894,7 +902,7 @@ public virtual void Discriminator_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Discriminator"") .IsRequired() @@ -954,7 +962,7 @@ public virtual void Properties_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -1052,7 +1060,7 @@ public virtual void Alternate_keys_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -1090,7 +1098,7 @@ public virtual void Indexes_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -1126,7 +1134,7 @@ public virtual void Indexes_are_stored_in_snapshot_including_composite_index() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -1167,7 +1175,7 @@ public virtual void Foreign_keys_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -1179,7 +1187,7 @@ public virtual void Foreign_keys_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -1250,7 +1258,7 @@ public virtual void Many_to_many_join_table_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasColumnType(""nvarchar(max)""); @@ -1265,7 +1273,7 @@ public virtual void Many_to_many_join_table_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Description"") .HasColumnType(""nvarchar(max)""); @@ -1391,7 +1399,7 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasColumnType(""nvarchar(max)""); @@ -1406,7 +1414,7 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Description"") .HasColumnType(""nvarchar(max)""); @@ -1560,7 +1568,7 @@ public virtual void Shared_columns_are_stored_in_the_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnUpdateSometimes() @@ -1668,7 +1676,7 @@ public virtual void AlternateKey_name_preserved_when_generic() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Property"") .HasColumnType(""uniqueidentifier""); @@ -1705,7 +1713,7 @@ public virtual void Discriminator_of_enum() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .HasColumnType(""bigint""); @@ -1737,7 +1745,7 @@ public virtual void Discriminator_of_enum_to_string() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .IsRequired() @@ -1807,7 +1815,7 @@ public virtual void Owned_types_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id"") .HasName(""PK_Custom""); @@ -1885,7 +1893,7 @@ public virtual void Owned_types_are_stored_in_snapshot() b1.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b1.Property(""EntityWithOnePropertyId"") .HasColumnType(""int""); @@ -2030,7 +2038,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id"") .HasName(""PK_Custom""); @@ -2108,7 +2116,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b1.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b1.Property(""EntityWithOnePropertyId"") .HasColumnType(""int""); @@ -2218,7 +2226,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -2381,15 +2389,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .UseIdentityColumns() - .HasAnnotation(""Relational:MaxIdentifierLength"", 128); + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwner"", b => { b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -2406,7 +2414,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b1.Property(""TestEnum"") .HasColumnType(""int""); @@ -2486,8 +2494,8 @@ public virtual void Property_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn() - .HasAnnotation(""AnnotationName"", ""AnnotationValue""); + .HasAnnotation(""AnnotationName"", ""AnnotationValue"") + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -2514,7 +2522,7 @@ public virtual void Custom_value_generator_is_ignored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -2537,7 +2545,7 @@ public virtual void Property_isNullable_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .IsRequired() @@ -2567,7 +2575,7 @@ public virtual void Property_ValueGenerated_value_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAdd() @@ -2634,7 +2642,7 @@ public virtual void Property_maxLength_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasMaxLength(100) @@ -2660,7 +2668,7 @@ public virtual void Property_unicodeness_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .IsUnicode(false) @@ -2686,7 +2694,7 @@ public virtual void Property_fixedlengthness_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasMaxLength(100) @@ -2720,7 +2728,7 @@ public virtual void Many_facets_chained_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasMaxLength(100) @@ -2758,7 +2766,7 @@ public virtual void Property_concurrencyToken_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .IsConcurrencyToken() @@ -2788,7 +2796,7 @@ public virtual void Property_column_name_annotation_is_stored_in_snapshot_as_flu b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int"") @@ -2818,7 +2826,7 @@ public virtual void Property_column_type_annotation_is_stored_in_snapshot_as_flu b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""CType""); @@ -2847,7 +2855,7 @@ public virtual void Property_default_value_annotation_is_stored_in_snapshot_as_f b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAdd() @@ -2878,7 +2886,7 @@ public virtual void Property_default_value_annotation_is_stored_in_snapshot_as_f b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAdd() @@ -2910,7 +2918,7 @@ public virtual void Property_default_value_sql_annotation_is_stored_in_snapshot_ b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAdd() @@ -2941,7 +2949,7 @@ public virtual void Property_default_value_sql_annotation_is_stored_in_snapshot_ b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAdd() @@ -2972,7 +2980,7 @@ public virtual void Property_computed_column_sql_annotation_is_stored_in_snapsho b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAddOrUpdate() @@ -3003,7 +3011,7 @@ public virtual void Property_computed_column_sql_stored_annotation_is_stored_in_ b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAddOrUpdate() @@ -3038,7 +3046,7 @@ public virtual void Property_computed_column_sql_annotation_is_stored_in_snapsho b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .ValueGeneratedOnAddOrUpdate() @@ -3065,7 +3073,7 @@ public virtual void Property_default_value_of_enum_type_is_stored_in_snapshot_wi b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .ValueGeneratedOnAdd() @@ -3099,7 +3107,7 @@ public virtual void Property_enum_type_is_stored_in_snapshot_with_custom_convers b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .IsRequired() @@ -3140,7 +3148,7 @@ public virtual void Property_of_nullable_enum() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .HasColumnType(""bigint""); @@ -3166,7 +3174,7 @@ public virtual void Property_of_enum_to_nullable() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .HasColumnType(""bigint""); @@ -3191,7 +3199,7 @@ public virtual void Property_of_nullable_enum_to_string() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Day"") .HasColumnType(""nvarchar(max)""); @@ -3221,7 +3229,7 @@ public virtual void Property_multiple_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int"") @@ -3268,14 +3276,14 @@ public virtual void Property_without_column_type() AddBoilerPlate( @" modelBuilder - .UseIdentityColumns(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity(""Building"", b => { b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -3313,7 +3321,9 @@ public virtual void Property_with_identity_column() { b.Property(""Id"") .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:IdentityIncrement"", 1) + .HasAnnotation(""SqlServer:IdentitySeed"", 1) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -3353,7 +3363,9 @@ public virtual void Property_with_identity_column_custom_seed() { b.Property(""Id"") .HasColumnType(""int"") - .UseIdentityColumn(5); + .HasAnnotation(""SqlServer:IdentityIncrement"", 1) + .HasAnnotation(""SqlServer:IdentitySeed"", 5) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -3393,7 +3405,9 @@ public virtual void Property_with_identity_column_custom_increment() { b.Property(""Id"") .HasColumnType(""int"") - .UseIdentityColumn(1, 5); + .HasAnnotation(""SqlServer:IdentityIncrement"", 5) + .HasAnnotation(""SqlServer:IdentitySeed"", 1) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -3433,7 +3447,9 @@ public virtual void Property_with_identity_column_custom_seed_increment() { b.Property(""Id"") .HasColumnType(""int"") - .UseIdentityColumn(5, 5); + .HasAnnotation(""SqlServer:IdentityIncrement"", 5) + .HasAnnotation(""SqlServer:IdentitySeed"", 5) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -3470,7 +3486,7 @@ public virtual void Key_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3503,7 +3519,7 @@ public virtual void Key_name_annotation_is_stored_in_snapshot_as_fluent_api() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3537,7 +3553,7 @@ public virtual void Key_multiple_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3581,7 +3597,7 @@ public virtual void Index_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3613,7 +3629,7 @@ public virtual void Index_isUnique_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3647,7 +3663,7 @@ public virtual void Index_database_name_annotation_is_stored_in_snapshot_as_flue b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3685,7 +3701,7 @@ public virtual void Index_filter_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3720,7 +3736,7 @@ public virtual void Index_multiple_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -3762,7 +3778,7 @@ public virtual void Index_with_default_constraint_name_exceeding_max() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasColumnType(""nvarchar(max)""); @@ -3792,7 +3808,7 @@ public virtual void IndexAttribute_causes_column_to_have_key_or_index_column_len b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""FirstName"") .HasColumnType(""nvarchar(450)""); @@ -3835,7 +3851,7 @@ public virtual void IndexAttribute_name_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""FirstName"") .HasColumnType(""nvarchar(450)""); @@ -3882,7 +3898,7 @@ public virtual void IndexAttribute_IsUnique_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""FirstName"") .HasColumnType(""nvarchar(450)""); @@ -3918,6 +3934,41 @@ public virtual void IndexAttribute_IsUnique_is_stored_in_snapshot() }); } + [ConditionalFact] + public virtual void IndexAttribute_IncludeProperties_generated_without_fluent_api() + { + Test( + builder => builder.Entity( + x => + { + x.HasIndex(e => e.Id).IncludeProperties(e => e.Name); + }), + AddBoilerPlate( + GetHeading() + + @" + modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => + { + b.Property(""Id"") + .ValueGeneratedOnAdd() + .HasColumnType(""int"") + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); + + b.Property(""Name"") + .HasColumnType(""nvarchar(max)""); + + b.HasKey(""Id""); + + b.HasIndex(""Id"") + .HasAnnotation(""SqlServer:Include"", new[] { ""Name"" }); + + b.ToTable(""EntityWithStringProperty""); + });", usingSystem: true), + model => { + var index = model.GetEntityTypes().First().GetIndexes().First(); + Assert.Equal("Name", Assert.Single(index.GetIncludeProperties())); + }); + } + #endregion #region ForeignKey @@ -3942,7 +3993,7 @@ public virtual void ForeignKey_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -3954,7 +4005,7 @@ public virtual void ForeignKey_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4018,7 +4069,7 @@ public virtual void ForeignKey_isRequired_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .IsRequired() @@ -4072,7 +4123,7 @@ public virtual void ForeignKey_isUnique_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Name"") .HasColumnType(""nvarchar(450)""); @@ -4128,7 +4179,7 @@ public virtual void ForeignKey_deleteBehavior_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4181,7 +4232,7 @@ public virtual void ForeignKey_deleteBehavior_is_stored_in_snapshot_for_one_to_o b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4242,7 +4293,7 @@ public virtual void ForeignKey_name_preserved_when_generic() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Property"") .HasColumnType(""uniqueidentifier""); @@ -4310,7 +4361,7 @@ public virtual void ForeignKey_constraint_name_is_stored_in_snapshot_as_fluent_a b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -4322,7 +4373,7 @@ public virtual void ForeignKey_constraint_name_is_stored_in_snapshot_as_fluent_a b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4376,7 +4427,7 @@ public virtual void ForeignKey_multiple_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -4388,7 +4439,7 @@ public virtual void ForeignKey_multiple_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4445,7 +4496,7 @@ public virtual void Do_not_generate_entity_type_builder_again_if_no_foreign_key_ b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Discriminator"") .IsRequired() @@ -4468,7 +4519,7 @@ public virtual void Do_not_generate_entity_type_builder_again_if_no_foreign_key_ b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -4523,7 +4574,7 @@ public virtual void ForeignKey_principal_key_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4588,7 +4639,7 @@ public virtual void ForeignKey_principal_key_with_non_default_name_is_stored_in_ b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4652,7 +4703,7 @@ public virtual void Navigation_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -4664,7 +4715,7 @@ public virtual void Navigation_annotations_are_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4719,7 +4770,7 @@ public virtual void Navigation_isRequired_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.HasKey(""Id""); @@ -4731,7 +4782,7 @@ public virtual void Navigation_isRequired_is_stored_in_snapshot() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""AlternateId"") .HasColumnType(""int""); @@ -4924,15 +4975,15 @@ protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 modelBuilder - .UseIdentityColumns() - .HasAnnotation(""Relational:MaxIdentifierLength"", 128); + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithManyProperties"", b => { b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .UseIdentityColumn(); + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn); b.Property(""Boolean"") .HasColumnType(""bit""); @@ -5270,8 +5321,8 @@ protected override void BuildModel(ModelBuilder modelBuilder) protected virtual string GetHeading(bool empty = false) => @" modelBuilder - .UseIdentityColumns() - .HasAnnotation(""Relational:MaxIdentifierLength"", 128);" + .HasAnnotation(""Relational:MaxIdentifierLength"", 128) + .HasAnnotation(""SqlServer:ValueGenerationStrategy"", SqlServerValueGenerationStrategy.IdentityColumn);" + (empty ? null : @"