diff --git a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs index 98c2acb0ef8..f383ae43fc2 100644 --- a/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs +++ b/src/EFCore.Relational/Extensions/RelationalEntityTypeExtensions.cs @@ -14,6 +14,9 @@ namespace Microsoft.EntityFrameworkCore; /// public static class RelationalEntityTypeExtensions { + private static readonly bool QuirkEnabled29899 + = AppContext.TryGetSwitch("Microsoft.EntityFrameworkCore.Issue29899", out var enabled) && enabled; + /// /// Gets the name used for the mapped using /// . @@ -146,7 +149,7 @@ public static void SetTableName(this IMutableEntityType entityType, string? name } return entityType.BaseType != null - ? entityType.GetRootType().GetSchema() + ? entityType.GetRootType().GetSchema() ?? (QuirkEnabled29899 ? null : GetDefaultSchema(entityType)) : GetDefaultSchema(entityType); } diff --git a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs index 14c43c342a7..c36838476d4 100644 --- a/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs +++ b/test/EFCore.Design.Tests/Migrations/ModelSnapshotSqlServerTest.cs @@ -331,6 +331,7 @@ public virtual void Model_annotations_are_stored_in_snapshot() AddBoilerPlate( @" modelBuilder + .HasDefaultSchema(""DefaultSchema"") .HasAnnotation(""AnnotationName"", ""AnnotationValue"") .HasAnnotation(""Relational:MaxIdentifierLength"", 128); @@ -340,7 +341,7 @@ public virtual void Model_annotations_are_stored_in_snapshot() SqlServerModelBuilderExtensions.HasPerformanceLevelSql(modelBuilder, ""'S0'"");"), o => { - Assert.Equal(8, o.GetAnnotations().Count()); + Assert.Equal(9, o.GetAnnotations().Count()); Assert.Equal("AnnotationValue", o["AnnotationName"]); }); @@ -355,7 +356,9 @@ public virtual void Model_Fluent_APIs_are_properly_generated() }, AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseHiLo(modelBuilder, ""EntityFrameworkHiLoSequence""); @@ -372,7 +375,7 @@ public virtual void Model_Fluent_APIs_are_properly_generated() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => { @@ -393,7 +396,9 @@ public virtual void Model_fluent_APIs_for_sequence_key_are_properly_generated() }, AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseKeySequences(modelBuilder, ""Sequence""); @@ -404,13 +409,13 @@ public virtual void Model_fluent_APIs_for_sequence_key_are_properly_generated() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .HasDefaultValueSql(""NEXT VALUE FOR [EntityWithOnePropertySequence]""); + .HasDefaultValueSql(""NEXT VALUE FOR [DefaultSchema].[EntityWithOnePropertySequence]""); SqlServerPropertyBuilderExtensions.UseSequence(b.Property(""Id"")); b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => { @@ -464,7 +469,7 @@ public virtual void Entities_are_stored_in_model_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -480,7 +485,7 @@ public virtual void Entities_are_stored_in_model_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -516,7 +521,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() b.HasKey(""Id""); - b.ToTable(""AbstractBase""); + b.ToTable(""AbstractBase"", ""DefaultSchema""); b.UseTptMappingStrategy(); }); @@ -525,7 +530,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() { b.HasBaseType(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+AbstractBase""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity"", b => @@ -548,7 +553,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() });"), model => { - Assert.Equal(4, model.GetAnnotations().Count()); + Assert.Equal(5, model.GetAnnotations().Count()); Assert.Equal(3, model.GetEntityTypes().Count()); var abstractBase = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+AbstractBase"); @@ -557,6 +562,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT() var baseType = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+BaseEntity"); Assert.Equal("BaseEntity", baseType.GetTableName()); + Assert.Equal("DefaultSchema", baseType.GetSchema()); var derived = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity"); Assert.Equal("DerivedEntity", derived.GetTableName()); @@ -588,7 +594,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT_with_one_exclu b.HasKey(""Id""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); b.UseTptMappingStrategy(); }); @@ -616,7 +622,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPT_with_one_exclu });"), o => { - Assert.Equal(4, o.GetAnnotations().Count()); + Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal( "DerivedEntity", @@ -640,7 +646,7 @@ public void Views_are_stored_in_the_model_snapshot() b.ToTable((string)null); - b.ToView(""EntityWithOneProperty"", (string)null); + b.ToView(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => Assert.Equal("EntityWithOneProperty", o.GetEntityTypes().Single().GetViewName())); @@ -691,7 +697,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPC() b.Property(""Id"") .ValueGeneratedOnAdd() .HasColumnType(""int"") - .HasDefaultValueSql(""NEXT VALUE FOR [AbstractBaseSequence]""); + .HasDefaultValueSql(""NEXT VALUE FOR [DefaultSchema].[AbstractBaseSequence]""); SqlServerPropertyBuilderExtensions.UseSequence(b.Property(""Id"")); @@ -706,7 +712,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPC() { b.HasBaseType(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+AbstractBase""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedEntity"", b => @@ -722,7 +728,7 @@ public virtual void Entities_are_stored_in_model_snapshot_for_TPC() });"), model => { - Assert.Equal(5, model.GetAnnotations().Count()); + Assert.Equal(6, model.GetAnnotations().Count()); Assert.Equal(3, model.GetEntityTypes().Count()); var abstractBase = model.FindEntityType("Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+AbstractBase"); @@ -751,13 +757,13 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() b.Property("Shadow").HasColumnName("Shadow"); b.ToTable( - "Order", tb => + "Order", "DefaultSchema", tb => { tb.Property(e => e.Id).UseIdentityColumn(2, 3).HasAnnotation("fii", "arr"); tb.Property("Shadow"); }); b.SplitToTable( - "SplitOrder", sb => + "SplitOrder", "DefaultSchema", sb => { sb.Property("Shadow"); sb.HasTrigger("splitTrigger").HasAnnotation("oof", "rab"); @@ -771,12 +777,12 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() od.Property("BillingShadow"); od.ToTable( - "SplitOrder", tb => + "SplitOrder", "DefaultSchema", tb => { tb.Property("BillingShadow").HasColumnName("Shadow"); }); od.SplitToTable( - "BillingDetails", sb => + "BillingDetails", "DefaultSchema", sb => { sb.Property("BillingShadow").HasColumnName("Shadow"); }); @@ -789,12 +795,12 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() od.Property("ShippingShadow"); od.ToTable( - "Order", tb => + "Order", "DefaultSchema", tb => { tb.Property("ShippingShadow").HasColumnName("Shadow"); }); od.SplitToTable( - "ShippingDetails", sb => + "ShippingDetails", "DefaultSchema", sb => { sb.Property("ShippingShadow"); }); @@ -818,7 +824,7 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() b.HasKey(""Id""); - b.ToTable(""Order"", null, t => + b.ToTable(""Order"", ""DefaultSchema"", t => { t.Property(""Id"") .HasAnnotation(""fii"", ""arr"") @@ -829,7 +835,7 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() t.Property(""Shadow""); }); - b.SplitToTable(""SplitOrder"", null, t => + b.SplitToTable(""SplitOrder"", ""DefaultSchema"", t => { t.HasTrigger(""splitTrigger"") .HasAnnotation(""oof"", ""rab""); @@ -858,13 +864,13 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() b1.HasKey(""OrderId""); - b1.ToTable(""SplitOrder"", null, t => + b1.ToTable(""SplitOrder"", ""DefaultSchema"", t => { t.Property(""BillingShadow"") .HasColumnName(""Shadow""); }); - b1.SplitToTable(""BillingDetails"", null, t => + b1.SplitToTable(""BillingDetails"", ""DefaultSchema"", t => { t.Property(""BillingShadow"") .HasColumnName(""Shadow""); @@ -889,7 +895,7 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() b2.HasKey(""OrderDetailsOrderId""); - b2.ToTable(""SplitOrder""); + b2.ToTable(""SplitOrder"", ""DefaultSchema""); b2.WithOwner() .HasForeignKey(""OrderDetailsOrderId""); @@ -908,13 +914,13 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() b1.HasKey(""OrderId""); - b1.ToTable(""Order"", null, t => + b1.ToTable(""Order"", ""DefaultSchema"", t => { t.Property(""ShippingShadow"") .HasColumnName(""Shadow""); }); - b1.SplitToTable(""ShippingDetails"", null, t => + b1.SplitToTable(""ShippingDetails"", ""DefaultSchema"", t => { t.Property(""ShippingShadow""); }); @@ -938,7 +944,7 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_tables() b2.HasKey(""OrderDetailsOrderId""); - b2.ToTable(""ShippingDetails"", (string)null); + b2.ToTable(""ShippingDetails"", ""DefaultSchema""); b2.WithOwner() .HasForeignKey(""OrderDetailsOrderId""); @@ -1081,12 +1087,12 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_views() b.ToTable((string)null); - b.ToView(""EntityWithOneProperty"", null, v => + b.ToView(""EntityWithOneProperty"", ""DefaultSchema"", v => { v.Property(""Shadow""); }); - b.SplitToView(""SplitView"", null, v => + b.SplitToView(""SplitView"", ""DefaultSchema"", v => { v.Property(""Shadow""); }); @@ -1106,13 +1112,13 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_views() b1.ToTable((string)null); - b1.ToView(""EntityWithOneProperty"", null, v => + b1.ToView(""EntityWithOneProperty"", ""DefaultSchema"", v => { v.Property(""AlternateId"") .HasColumnName(""SomeId""); }); - b1.SplitToView(""SplitView"", null, v => + b1.SplitToView(""SplitView"", ""DefaultSchema"", v => { v.Property(""AlternateId"") .HasColumnName(""SomeOtherId""); @@ -1141,7 +1147,7 @@ public virtual void Entity_splitting_is_stored_in_snapshot_with_views() Assert.Empty(relationalModel.Tables); Assert.Equal(2, relationalModel.Views.Count()); - var mainView = relationalModel.FindView(entityWithOneProperty.GetViewName(), entityWithOneProperty.GetSchema()); + var mainView = relationalModel.FindView(entityWithOneProperty.GetViewName(), "DefaultSchema"); var fragment = entityWithOneProperty.GetMappingFragments().Single(); var splitView = relationalModel.FindView(fragment.StoreObject.Name, fragment.StoreObject.Schema); @@ -1288,7 +1294,7 @@ public virtual void Sequence_is_stored_in_snapshot_as_fluent_api() .HasAnnotation(""foo"", ""bar"");"), model => { - Assert.Equal(5, model.GetAnnotations().Count()); + Assert.Equal(6, model.GetAnnotations().Count()); var sequence = model.GetSequences().Single(); Assert.Equal(2, sequence.StartValue); @@ -1364,7 +1370,7 @@ public virtual void CheckConstraint_is_stored_in_snapshot_as_fluent_api() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties"", t => + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema"", t => { t.HasCheckConstraint(""AlternateId"", ""AlternateId > Id"") .HasName(""CK_Customer_AlternateId"") @@ -1404,7 +1410,7 @@ public virtual void CheckConstraint_is_only_stored_in_snapshot_once_for_TPH() b.HasKey(""Id""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); b.HasDiscriminator(""Discriminator"").HasValue(""BaseEntity""); @@ -1453,7 +1459,7 @@ public virtual void Trigger_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty"", t => + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema"", t => { t.HasTrigger(""SomeTrigger"") .HasDatabaseName(""SomeTrg"") @@ -1495,7 +1501,7 @@ public virtual void Triggers_and_ExcludeFromMigrations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty"", t => + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema"", t => { t.ExcludeFromMigrations(); @@ -1534,12 +1540,14 @@ public virtual void Model_use_identity_columns() builder => builder.UseIdentityColumns(), AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);"), o => { - Assert.Equal(4, o.GetAnnotations().Count()); + Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, o.GetValueGenerationStrategy()); Assert.Equal(1, o.GetIdentitySeed()); Assert.Equal(1, o.GetIdentityIncrement()); @@ -1551,12 +1559,14 @@ public virtual void Model_use_identity_columns_custom_seed() builder => builder.UseIdentityColumns(5), AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 5L);"), o => { - Assert.Equal(4, o.GetAnnotations().Count()); + Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, o.GetValueGenerationStrategy()); Assert.Equal(5, o.GetIdentitySeed()); Assert.Equal(1, o.GetIdentityIncrement()); @@ -1568,12 +1578,14 @@ public virtual void Model_use_identity_columns_custom_increment() builder => builder.UseIdentityColumns(increment: 5), AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 1L, 5);"), o => { - Assert.Equal(4, o.GetAnnotations().Count()); + Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, o.GetValueGenerationStrategy()); Assert.Equal(1, o.GetIdentitySeed()); Assert.Equal(5, o.GetIdentityIncrement()); @@ -1592,12 +1604,14 @@ public virtual void Model_use_identity_columns_custom_seed_increment() b.HasKey("Id"); - b.ToTable("Buildings"); + b.ToTable("Buildings", "DefaultSchema"); }); }, AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 9223372036854775807L, 5); @@ -1611,11 +1625,11 @@ public virtual void Model_use_identity_columns_custom_seed_increment() b.HasKey(""Id""); - b.ToTable(""Buildings"", (string)null); + b.ToTable(""Buildings"", ""DefaultSchema""); });"), o => { - Assert.Equal(4, o.GetAnnotations().Count()); + Assert.Equal(5, o.GetAnnotations().Count()); Assert.Equal(SqlServerValueGenerationStrategy.IdentityColumn, o.GetValueGenerationStrategy()); Assert.Equal(long.MaxValue, o.GetIdentitySeed()); Assert.Equal(5, o.GetIdentityIncrement()); @@ -1651,7 +1665,7 @@ public virtual void EntityType_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b.HasAnnotation(""AnnotationName"", ""AnnotationValue""); });"), @@ -1684,7 +1698,7 @@ public virtual void EntityType_Fluent_APIs_are_properly_generated() SqlServerKeyBuilderExtensions.IsClustered(b.HasKey(""Id""), false); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); SqlServerEntityTypeBuilderExtensions.IsMemoryOptimized(b); });"), @@ -1715,7 +1729,7 @@ public virtual void BaseType_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); b.HasDiscriminator(""Discriminator"").HasValue(""BaseEntity""); @@ -1784,7 +1798,7 @@ public virtual void Discriminator_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); b.HasDiscriminator(""Discriminator"").IsComplete(true).HasValue(""BaseEntity""); @@ -1859,7 +1873,7 @@ public virtual void Converted_discriminator_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""BaseEntityWithStructDiscriminator""); + b.ToTable(""BaseEntityWithStructDiscriminator"", ""DefaultSchema""); b.HasDiscriminator(""Discriminator"").IsComplete(true).HasValue(""Base""); @@ -1928,7 +1942,7 @@ public virtual void Properties_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -1962,7 +1976,7 @@ public virtual void Primary_key_is_stored_in_snapshot() b.HasKey(""Id"", ""AlternateId""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -1986,7 +2000,7 @@ public void HasNoKey_is_handled() b.Property(""Id"") .HasColumnType(""int""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => { @@ -2023,7 +2037,7 @@ public virtual void Alternate_keys_are_stored_in_snapshot() b.HasAlternateKey(""Id"", ""AlternateId""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -2060,7 +2074,7 @@ public virtual void Indexes_are_stored_in_snapshot() b.HasIndex(""AlternateId""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -2095,7 +2109,7 @@ public virtual void Indexes_are_stored_in_snapshot_including_composite_index() b.HasIndex(""Id"", ""AlternateId""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -2130,7 +2144,7 @@ public virtual void Foreign_keys_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -2149,7 +2163,7 @@ public virtual void Foreign_keys_are_stored_in_snapshot() b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -2349,7 +2363,7 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i b.HasIndex(""RightsId""); - b.ToTable(""MyJoinTable"", (string)null); + b.ToTable(""MyJoinTable"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyLeft"", b => @@ -2365,7 +2379,7 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i b.HasKey(""Id""); - b.ToTable(""ManyToManyLeft""); + b.ToTable(""ManyToManyLeft"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+ManyToManyRight"", b => @@ -2381,7 +2395,7 @@ public virtual void Can_override_table_name_for_many_to_many_join_table_stored_i b.HasKey(""Id""); - b.ToTable(""ManyToManyRight""); + b.ToTable(""ManyToManyRight"", ""DefaultSchema""); }); modelBuilder.Entity(""ManyToManyLeftManyToManyRight"", b => @@ -2490,7 +2504,7 @@ public virtual void TableName_preserved_when_generic() b.HasKey(""Id""); - b.ToTable(""EntityWithGenericKey""); + b.ToTable(""EntityWithGenericKey"", ""DefaultSchema""); });", usingSystem: true), model => { @@ -2540,7 +2554,7 @@ public virtual void Shared_columns_are_stored_in_the_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithProperties"", (string)null); + b.ToTable(""EntityWithProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -2555,7 +2569,7 @@ public virtual void Shared_columns_are_stored_in_the_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithProperties"", (string)null); + b.ToTable(""EntityWithProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -2603,7 +2617,7 @@ public virtual void PrimaryKey_name_preserved_when_generic() b.HasKey(""Id""); - b.ToTable(""EntityWithGenericKey""); + b.ToTable(""EntityWithGenericKey"", ""DefaultSchema""); });", usingSystem: true), model => { @@ -2648,7 +2662,7 @@ public virtual void AlternateKey_name_preserved_when_generic() b.HasAlternateKey(""Property""); - b.ToTable(""EntityWithGenericProperty""); + b.ToTable(""EntityWithGenericProperty"", ""DefaultSchema""); });", usingSystem: true), model => { @@ -2683,7 +2697,7 @@ public virtual void Discriminator_of_enum() b.HasKey(""Id""); - b.ToTable(""EntityWithEnumType""); + b.ToTable(""EntityWithEnumType"", ""DefaultSchema""); b.HasDiscriminator(""Day""); });"), @@ -2715,7 +2729,7 @@ public virtual void Discriminator_of_enum_to_string() b.HasKey(""Id""); - b.ToTable(""EntityWithEnumType""); + b.ToTable(""EntityWithEnumType"", ""DefaultSchema""); b.HasDiscriminator(""Day""); });"), @@ -2763,7 +2777,7 @@ public virtual void Temporal_table_information_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); b.ToTable(tb => tb.IsTemporal(ttb => { @@ -2824,11 +2838,11 @@ public virtual void Temporal_table_information_is_stored_in_snapshot_minimal_set b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); b.ToTable(tb => tb.IsTemporal(ttb => { - ttb.UseHistoryTable(""EntityWithStringPropertyHistory""); + ttb.UseHistoryTable(""EntityWithStringPropertyHistory"", ""DefaultSchema""); ttb .HasPeriodStart(""PeriodStart"") .HasColumnName(""PeriodStart""); @@ -2909,7 +2923,7 @@ public virtual void Owned_types_are_stored_in_snapshot() b.HasKey(""Id"") .HasName(""PK_Custom""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b.HasData( new @@ -2925,7 +2939,7 @@ public virtual void Owned_types_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringKey""); + b.ToTable(""EntityWithStringKey"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", b => @@ -2952,7 +2966,7 @@ public virtual void Owned_types_are_stored_in_snapshot() SqlServerIndexBuilderExtensions.IncludeProperties(b1.HasIndex(""Id""), new[] { ""AlternateId"" }); - b1.ToTable(""EntityWithOneProperty""); + b1.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b1.WithOwner(""EntityWithOneProperty"") .HasForeignKey(""AlternateId"") @@ -3005,7 +3019,7 @@ public virtual void Owned_types_are_stored_in_snapshot() b1.HasIndex(""EntityWithStringKeyId""); - b1.ToTable(""EntityWithStringProperty""); + b1.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); b1.HasOne(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", ""EntityWithOneProperty"") .WithOne() @@ -3105,7 +3119,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b.HasData( new EntityWithOneProperty { Id = 1 }); - b.ToTable("EntityWithOneProperty", e => e.ExcludeFromMigrations()); + b.ToTable("EntityWithOneProperty", "DefaultSchema", e => e.ExcludeFromMigrations()); }); builder.Entity( @@ -3137,7 +3151,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b.HasKey(""Id"") .HasName(""PK_Custom""); - b.ToTable(""EntityWithOneProperty"", null, t => + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema"", t => { t.ExcludeFromMigrations(); }); @@ -3156,7 +3170,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b.HasKey(""Id""); - b.ToTable(""EntityWithStringKey"", null, t => + b.ToTable(""EntityWithStringKey"", ""DefaultSchema"", t => { t.ExcludeFromMigrations(); }); @@ -3184,7 +3198,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b1.HasIndex(""Id""); - b1.ToTable(""EntityWithOneProperty""); + b1.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b1.WithOwner(""EntityWithOneProperty"") .HasForeignKey(""AlternateId"") @@ -3237,7 +3251,7 @@ public virtual void Owned_types_are_stored_in_snapshot_when_excluded() b1.HasIndex(""EntityWithStringKeyId""); - b1.ToTable(""EntityWithStringProperty"", null, t => + b1.ToTable(""EntityWithStringProperty"", ""DefaultSchema"", t => { t.ExcludeFromMigrations(); }); @@ -3333,7 +3347,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""Order""); + b.ToTable(""Order"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+Order"", b => @@ -3345,7 +3359,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b1.HasKey(""OrderId""); - b1.ToTable(""Order""); + b1.ToTable(""Order"", ""DefaultSchema""); b1.WithOwner() .HasForeignKey(""OrderId""); @@ -3360,7 +3374,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b2.HasKey(""OrderDetailsOrderId""); - b2.ToTable(""Order""); + b2.ToTable(""Order"", ""DefaultSchema""); b2.WithOwner() .HasForeignKey(""OrderDetailsOrderId""); @@ -3376,7 +3390,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b1.HasKey(""OrderId""); - b1.ToTable(""Order""); + b1.ToTable(""Order"", ""DefaultSchema""); b1.WithOwner() .HasForeignKey(""OrderId""); @@ -3391,7 +3405,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b2.HasKey(""OrderDetailsOrderId""); - b2.ToTable(""Order""); + b2.ToTable(""Order"", ""DefaultSchema""); b2.WithOwner() .HasForeignKey(""OrderDetailsOrderId""); @@ -3407,7 +3421,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b1.HasKey(""OrderId""); - b1.ToTable(""Order""); + b1.ToTable(""Order"", ""DefaultSchema""); b1.WithOwner() .HasForeignKey(""OrderId""); @@ -3422,7 +3436,7 @@ public virtual void Shared_owned_types_are_stored_in_snapshot() b2.HasKey(""OrderInfoOrderId""); - b2.ToTable(""Order""); + b2.ToTable(""Order"", ""DefaultSchema""); b2.WithOwner() .HasForeignKey(""OrderInfoOrderId""); @@ -3491,7 +3505,9 @@ partial class Snapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -3505,7 +3521,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey(""Id""); - b.ToTable(""TestOwner""); + b.ToTable(""TestOwner"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwner"", b => @@ -3525,7 +3541,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.ToTable((string)null); - b1.ToView(""OwnedView"", (string)null); + b1.ToView(""OwnedView"", ""DefaultSchema""); b1.WithOwner() .HasForeignKey(""TestOwnerId""); @@ -3575,7 +3591,9 @@ partial class Snapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -3589,7 +3607,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey(""Id""); - b.ToTable(""TestOwner""); + b.ToTable(""TestOwner"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+TestOwner"", b => @@ -3610,7 +3628,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b1.HasKey(""TestOwnerId"", ""Id""); - b1.ToTable(""TestOwnee"", t => + b1.ToTable(""TestOwnee"", ""DefaultSchema"", t => { t.HasCheckConstraint(""CK_TestOwnee_TestEnum_Enum_Constraint"", ""[TestEnum] IN (0, 1, 2)""); }); @@ -3676,7 +3694,7 @@ public virtual void Owned_types_mapped_to_json_are_stored_in_snapshot() b.HasKey(""Id"") .HasName(""PK_Custom""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", b => @@ -3692,7 +3710,7 @@ public virtual void Owned_types_mapped_to_json_are_stored_in_snapshot() b1.HasKey(""EntityWithOnePropertyId""); - b1.ToTable(""EntityWithOneProperty""); + b1.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b1.ToJson(""EntityWithTwoProperties""); @@ -3706,7 +3724,7 @@ public virtual void Owned_types_mapped_to_json_are_stored_in_snapshot() b2.HasKey(""EntityWithTwoPropertiesEntityWithOnePropertyId""); - b2.ToTable(""EntityWithOneProperty""); + b2.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b2.WithOwner() .HasForeignKey(""EntityWithTwoPropertiesEntityWithOnePropertyId""); @@ -3725,7 +3743,7 @@ public virtual void Owned_types_mapped_to_json_are_stored_in_snapshot() b3.HasKey(""EntityWithStringKeyEntityWithTwoPropertiesEntityWithOnePropertyId"", ""Id""); - b3.ToTable(""EntityWithOneProperty""); + b3.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); b3.HasAnnotation(""Relational:JsonPropertyName"", ""JsonProps""); @@ -3852,7 +3870,7 @@ public virtual void Property_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => Assert.Equal("AnnotationValue", o.GetEntityTypes().First().FindProperty("Id")["AnnotationName"]) ); @@ -3878,7 +3896,7 @@ public virtual void Custom_value_generator_is_ignored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => Assert.Null(o.GetEntityTypes().First().FindProperty("Id")[CoreAnnotationNames.ValueGeneratorFactory]) ); @@ -3904,7 +3922,7 @@ public virtual void Property_isNullable_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), o => Assert.False(o.GetEntityTypes().First().FindProperty("Name").IsNullable)); @@ -3934,7 +3952,7 @@ public virtual void Property_ValueGenerated_value_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });", usingSystem: true), o => Assert.Equal(ValueGenerated.OnAdd, o.GetEntityTypes().First().FindProperty("AlternateId").ValueGenerated)); @@ -3965,7 +3983,7 @@ public virtual void Property_ValueGenerated_non_identity() b.HasKey(""Id""); - b.ToTable(""EntityWithEnumType""); + b.ToTable(""EntityWithEnumType"", ""DefaultSchema""); });"), model => { @@ -3998,7 +4016,7 @@ public virtual void Property_maxLength_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), o => Assert.Equal(100, o.GetEntityTypes().First().FindProperty("Name").GetMaxLength())); @@ -4023,7 +4041,7 @@ public virtual void Property_unicodeness_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), o => Assert.False(o.GetEntityTypes().First().FindProperty("Name").IsUnicode())); @@ -4049,7 +4067,7 @@ public virtual void Property_fixedlengthness_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().First().FindProperty("Name").IsFixedLength())); @@ -4077,7 +4095,7 @@ public virtual void Property_precision_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithDecimalProperty""); + b.ToTable(""EntityWithDecimalProperty"", ""DefaultSchema""); });"), o => { @@ -4110,7 +4128,7 @@ public virtual void Property_precision_and_scale_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithDecimalProperty""); + b.ToTable(""EntityWithDecimalProperty"", ""DefaultSchema""); });"), o => { @@ -4149,7 +4167,7 @@ public virtual void Many_facets_chained_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), o => { @@ -4184,7 +4202,7 @@ public virtual void Property_concurrencyToken_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().First().FindProperty("AlternateId").IsConcurrencyToken)); @@ -4213,7 +4231,7 @@ public virtual void Property_column_name_annotation_is_stored_in_snapshot_as_flu b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal("CName", o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:ColumnName"])); @@ -4242,7 +4260,7 @@ public virtual void Property_column_name_on_specific_table_is_stored_in_snapshot b.HasKey(""Id""); - b.ToTable(""BaseEntity""); + b.ToTable(""BaseEntity"", ""DefaultSchema""); b.HasDiscriminator(""Discriminator"").HasValue(""BaseEntity""); @@ -4266,7 +4284,7 @@ public virtual void Property_column_name_on_specific_table_is_stored_in_snapshot b.Property(""Name"") .HasColumnType(""nvarchar(max)""); - b.ToTable(""BaseEntity"", t => + b.ToTable(""BaseEntity"", ""DefaultSchema"", t => { t.Property(""Name"") .HasColumnName(""DuplicateDerivedEntity_Name""); @@ -4288,7 +4306,7 @@ public virtual void Property_column_name_on_specific_table_is_stored_in_snapshot Assert.Equal( "DuplicateDerivedEntity_Name", t.FindProperty(nameof(DuplicateDerivedEntity.Name)) - .GetColumnName(StoreObjectIdentifier.Table(nameof(BaseEntity)))); + .GetColumnName(StoreObjectIdentifier.Table(nameof(BaseEntity), "DefaultSchema"))); } ); }); @@ -4317,7 +4335,7 @@ public virtual void Property_column_type_annotation_is_stored_in_snapshot_as_flu b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal("CType", o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:ColumnType"])); @@ -4347,7 +4365,7 @@ public virtual void Property_default_value_annotation_is_stored_in_snapshot_as_f b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal(1, o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:DefaultValue"])); @@ -4377,7 +4395,7 @@ public virtual void Property_default_value_annotation_is_stored_in_snapshot_as_f b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });", usingSystem: true), o => Assert.Equal(DBNull.Value, o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:DefaultValue"])); @@ -4408,7 +4426,7 @@ public virtual void Property_default_value_sql_annotation_is_stored_in_snapshot_ b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal(string.Empty, o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:DefaultValueSql"])); @@ -4438,7 +4456,7 @@ public virtual void Property_default_value_sql_annotation_is_stored_in_snapshot_ b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal("SQL", o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:DefaultValueSql"])); @@ -4468,7 +4486,7 @@ public virtual void Property_computed_column_sql_annotation_is_stored_in_snapsho b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal("SQL", o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:ComputedColumnSql"])); @@ -4498,7 +4516,7 @@ public virtual void Property_computed_column_sql_stored_annotation_is_stored_in_ b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -4532,7 +4550,7 @@ public virtual void Property_computed_column_sql_annotation_is_stored_in_snapsho b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal(string.Empty, o.GetEntityTypes().First().FindProperty("AlternateId")["Relational:ComputedColumnSql"])); @@ -4558,7 +4576,7 @@ public virtual void Property_default_value_of_enum_type_is_stored_in_snapshot_wi b.HasKey(""Id""); - b.ToTable(""EntityWithEnumType""); + b.ToTable(""EntityWithEnumType"", ""DefaultSchema""); });"), o => Assert.Equal(3L, o.GetEntityTypes().First().FindProperty("Day")["Relational:DefaultValue"])); @@ -4592,7 +4610,7 @@ public virtual void Property_enum_type_is_stored_in_snapshot_with_custom_convers b.HasKey(""Id""); - b.ToTable(""EntityWithEnumType""); + b.ToTable(""EntityWithEnumType"", ""DefaultSchema""); b.HasData( new @@ -4629,7 +4647,7 @@ public virtual void Property_of_nullable_enum() b.HasKey(""Id""); - b.ToTable(""EntityWithNullableEnumType""); + b.ToTable(""EntityWithNullableEnumType"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().First().FindProperty("Day").IsNullable)); @@ -4654,7 +4672,7 @@ public virtual void Property_of_enum_to_nullable() b.HasKey(""Id""); - b.ToTable(""EntityWithEnumType""); + b.ToTable(""EntityWithEnumType"", ""DefaultSchema""); });", usingSystem: true), o => Assert.False(o.GetEntityTypes().First().FindProperty("Day").IsNullable)); @@ -4678,7 +4696,7 @@ public virtual void Property_of_nullable_enum_to_string() b.HasKey(""Id""); - b.ToTable(""EntityWithNullableEnumType""); + b.ToTable(""EntityWithNullableEnumType"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().First().FindProperty("Day").IsNullable)); @@ -4709,7 +4727,7 @@ public virtual void Property_multiple_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -4738,7 +4756,7 @@ public virtual void Property_without_column_type() b.HasKey("Id"); - b.ToTable("Buildings"); + b.ToTable("Buildings", "DefaultSchema"); }); }, AddBoilerPlate( @@ -4754,7 +4772,7 @@ public virtual void Property_without_column_type() b.HasKey(""Id""); - b.ToTable(""Buildings"", (string)null); + b.ToTable(""Buildings"", ""DefaultSchema""); });"), o => { @@ -4774,7 +4792,7 @@ public virtual void Property_with_identity_column() b.HasKey("Id"); - b.ToTable("Buildings"); + b.ToTable("Buildings", "DefaultSchema"); }); }, AddBoilerPlate( @@ -4790,7 +4808,7 @@ public virtual void Property_with_identity_column() b.HasKey(""Id""); - b.ToTable(""Buildings"", (string)null); + b.ToTable(""Buildings"", ""DefaultSchema""); });"), o => { @@ -4812,7 +4830,7 @@ public virtual void Property_with_identity_column_custom_seed() b.HasKey("Id"); - b.ToTable("Buildings"); + b.ToTable("Buildings", "DefaultSchema"); }); }, AddBoilerPlate( @@ -4828,7 +4846,7 @@ public virtual void Property_with_identity_column_custom_seed() b.HasKey(""Id""); - b.ToTable(""Buildings"", (string)null); + b.ToTable(""Buildings"", ""DefaultSchema""); });"), o => { @@ -4850,7 +4868,7 @@ public virtual void Property_with_identity_column_custom_increment() b.HasKey("Id"); - b.ToTable("Buildings"); + b.ToTable("Buildings", "DefaultSchema"); }); }, AddBoilerPlate( @@ -4866,7 +4884,7 @@ public virtual void Property_with_identity_column_custom_increment() b.HasKey(""Id""); - b.ToTable(""Buildings"", (string)null); + b.ToTable(""Buildings"", ""DefaultSchema""); });"), o => { @@ -4888,7 +4906,7 @@ public virtual void Property_with_identity_column_custom_seed_increment() b.HasKey("Id"); - b.ToTable("Buildings"); + b.ToTable("Buildings", "DefaultSchema"); }); }, AddBoilerPlate( @@ -4904,7 +4922,7 @@ public virtual void Property_with_identity_column_custom_seed_increment() b.HasKey(""Id""); - b.ToTable(""Buildings"", (string)null); + b.ToTable(""Buildings"", ""DefaultSchema""); });"), o => { @@ -4939,7 +4957,7 @@ public virtual void Property_column_order_annotation_is_stored_in_snapshot_as_fl b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal(1, o.GetEntityTypes().First().FindProperty("AlternateId").GetColumnOrder())); @@ -4949,7 +4967,9 @@ public virtual void SQLServer_model_legacy_identity_seed_int_annotation() builder => builder.HasAnnotation(SqlServerAnnotationNames.IdentitySeed, 8), AddBoilerPlate( @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder, 8L);"), o => Assert.Equal(8L, o.GetIdentitySeed())); @@ -4979,7 +4999,7 @@ public virtual void SQLServer_property_legacy_identity_seed_int_annotation() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal(8L, o.GetEntityTypes().First().FindProperty("Id").GetIdentitySeed())); @@ -5015,7 +5035,7 @@ public virtual void Key_annotations_are_stored_in_snapshot() b.HasAlternateKey(""AlternateId"") .HasAnnotation(""AnnotationName"", ""AnnotationValue""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal( "AnnotationValue", o.GetEntityTypes().First().GetKeys().Where(k => !k.IsPrimaryKey()).First()["AnnotationName"])); @@ -5043,7 +5063,7 @@ public virtual void Key_Fluent_APIs_are_properly_generated() SqlServerKeyBuilderExtensions.IsClustered(b.HasKey(""Id"")); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().First().GetKeys().Single(k => k.IsPrimaryKey()).IsClustered())); @@ -5074,7 +5094,7 @@ public virtual void Key_name_annotation_is_stored_in_snapshot_as_fluent_api() b.HasAlternateKey(""AlternateId"") .HasName(""KeyName""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal( "KeyName", o.GetEntityTypes().First().GetKeys().Where(k => !k.IsPrimaryKey()).First()["Relational:Name"])); @@ -5108,7 +5128,7 @@ public virtual void Key_multiple_annotations_are_stored_in_snapshot() .HasName(""IndexName"") .HasAnnotation(""AnnotationName"", ""AnnotationValue""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -5150,7 +5170,7 @@ public virtual void Index_annotations_are_stored_in_snapshot() b.HasIndex(""AlternateId"") .HasAnnotation(""AnnotationName"", ""AnnotationValue""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal("AnnotationValue", o.GetEntityTypes().First().GetIndexes().First()["AnnotationName"])); @@ -5182,7 +5202,7 @@ public virtual void Index_Fluent_APIs_are_properly_generated() SqlServerIndexBuilderExtensions.IsClustered(b.HasIndex(""AlternateId"")); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().Single().GetIndexes().Single().IsClustered())); @@ -5213,7 +5233,7 @@ public virtual void Index_IsUnique_is_stored_in_snapshot() b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.True(o.GetEntityTypes().First().GetIndexes().First().IsUnique)); @@ -5301,7 +5321,7 @@ public virtual void Index_IsDescending_is_stored_in_snapshot() b.HasIndex(new[] { ""X"", ""Y"", ""Z"" }, ""IX_unspecified""); - b.ToTable(""EntityWithThreeProperties""); + b.ToTable(""EntityWithThreeProperties"", ""DefaultSchema""); });"), o => { @@ -5353,7 +5373,7 @@ public virtual void Index_database_name_annotation_is_stored_in_snapshot_as_flue b.HasIndex(""AlternateId"") .HasDatabaseName(""IndexName""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -5390,7 +5410,7 @@ public virtual void Index_filter_is_stored_in_snapshot() b.HasIndex(""AlternateId"") .HasFilter(""AlternateId <> 0""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => Assert.Equal( "AlternateId <> 0", @@ -5424,7 +5444,7 @@ public virtual void Index_multiple_annotations_are_stored_in_snapshot() b.HasIndex(new[] { ""AlternateId"" }, ""IndexName"") .HasAnnotation(""AnnotationName"", ""AnnotationValue""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); });"), o => { @@ -5467,7 +5487,7 @@ public virtual void Index_with_default_constraint_name_exceeding_max() b.HasIndex(""SomePropertyWithAnExceedinglyLongIdentifierThatCausesTheDefaultIndexNameToExceedTheMaximumIdentifierLimit""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), model => Assert.Equal(128, model.GetEntityTypes().First().GetIndexes().First().GetDatabaseName().Length)); @@ -5496,7 +5516,7 @@ public virtual void IndexAttribute_causes_column_to_have_key_or_index_column_len b.HasIndex(""FirstName"", ""LastName""); - b.ToTable(""EntityWithIndexAttribute""); + b.ToTable(""EntityWithIndexAttribute"", ""DefaultSchema""); });"), model => Assert.Collection( @@ -5538,7 +5558,7 @@ public virtual void IndexAttribute_name_is_stored_in_snapshot() b.HasIndex(new[] { ""FirstName"", ""LastName"" }, ""NamedIndex""); - b.ToTable(""EntityWithNamedIndexAttribute""); + b.ToTable(""EntityWithNamedIndexAttribute"", ""DefaultSchema""); });"), model => { @@ -5586,7 +5606,7 @@ public virtual void IndexAttribute_IsUnique_is_stored_in_snapshot() .IsUnique() .HasFilter(""[FirstName] IS NOT NULL AND [LastName] IS NOT NULL""); - b.ToTable(""EntityWithUniqueIndexAttribute""); + b.ToTable(""EntityWithUniqueIndexAttribute"", ""DefaultSchema""); });"), model => { @@ -5635,7 +5655,7 @@ public virtual void IndexAttribute_IncludeProperties_generated_without_fluent_ap SqlServerIndexBuilderExtensions.IncludeProperties(b.HasIndex(""Id""), new[] { ""Name"" }); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); });"), model => { @@ -5671,7 +5691,7 @@ public virtual void ForeignKey_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -5690,7 +5710,7 @@ public virtual void ForeignKey_annotations_are_stored_in_snapshot() b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -5734,7 +5754,7 @@ public virtual void ForeignKey_isRequired_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringKey""); + b.ToTable(""EntityWithStringKey"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -5754,7 +5774,7 @@ public virtual void ForeignKey_isRequired_is_stored_in_snapshot() b.HasIndex(""Name"") .IsUnique(); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -5787,7 +5807,7 @@ public virtual void ForeignKey_isUnique_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithStringKey""); + b.ToTable(""EntityWithStringKey"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -5805,7 +5825,7 @@ public virtual void ForeignKey_isUnique_is_stored_in_snapshot() b.HasIndex(""Name""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -5849,7 +5869,7 @@ public virtual void ForeignKey_with_non_primary_principal_is_stored_in_snapshot( b.HasKey(""Id""); - b.ToTable(""EntityWithStringAlternateKey""); + b.ToTable(""EntityWithStringAlternateKey"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -5867,7 +5887,7 @@ public virtual void ForeignKey_with_non_primary_principal_is_stored_in_snapshot( b.HasIndex(""Name""); - b.ToTable(""EntityWithStringProperty""); + b.ToTable(""EntityWithStringProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithStringProperty"", b => @@ -5905,7 +5925,7 @@ public virtual void ForeignKey_deleteBehavior_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -5921,7 +5941,7 @@ public virtual void ForeignKey_deleteBehavior_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", b => @@ -5957,7 +5977,7 @@ public virtual void ForeignKey_deleteBehavior_is_stored_in_snapshot_for_one_to_o b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -5973,7 +5993,7 @@ public virtual void ForeignKey_deleteBehavior_is_stored_in_snapshot_for_one_to_o b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", b => @@ -6018,7 +6038,7 @@ public virtual void ForeignKey_name_preserved_when_generic() b.HasKey(""Id""); - b.ToTable(""EntityWithGenericKey""); + b.ToTable(""EntityWithGenericKey"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithGenericProperty"", b => @@ -6036,7 +6056,7 @@ public virtual void ForeignKey_name_preserved_when_generic() b.HasIndex(""Property""); - b.ToTable(""EntityWithGenericProperty""); + b.ToTable(""EntityWithGenericProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithGenericProperty"", b => @@ -6099,7 +6119,7 @@ public virtual void ForeignKey_constraint_name_is_stored_in_snapshot_as_fluent_a b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6118,7 +6138,7 @@ public virtual void ForeignKey_constraint_name_is_stored_in_snapshot_as_fluent_a b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6165,7 +6185,7 @@ public virtual void ForeignKey_multiple_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6184,7 +6204,7 @@ public virtual void ForeignKey_multiple_annotations_are_stored_in_snapshot() b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6243,7 +6263,7 @@ public virtual void Do_not_generate_entity_type_builder_again_if_no_foreign_key_ b.HasIndex(""NavigationId""); - b.ToTable(""BaseType""); + b.ToTable(""BaseType"", ""DefaultSchema""); b.HasDiscriminator(""Discriminator"").HasValue(""BaseType""); @@ -6260,7 +6280,7 @@ public virtual void Do_not_generate_entity_type_builder_again_if_no_foreign_key_ b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+DerivedType"", b => @@ -6301,7 +6321,7 @@ public virtual void ForeignKey_principal_key_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6317,7 +6337,7 @@ public virtual void ForeignKey_principal_key_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", b => @@ -6365,7 +6385,7 @@ public virtual void ForeignKey_principal_key_with_non_default_name_is_stored_in_ b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6384,7 +6404,7 @@ public virtual void ForeignKey_principal_key_with_non_default_name_is_stored_in_ b.HasAlternateKey(""AlternateId"") .HasAnnotation(""Name"", ""Value""); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithOneProperty"", b => @@ -6441,7 +6461,7 @@ public virtual void Navigation_annotations_are_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6460,7 +6480,7 @@ public virtual void Navigation_annotations_are_stored_in_snapshot() b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6508,7 +6528,7 @@ public virtual void Navigation_isRequired_is_stored_in_snapshot() b.HasKey(""Id""); - b.ToTable(""EntityWithOneProperty""); + b.ToTable(""EntityWithOneProperty"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6527,7 +6547,7 @@ public virtual void Navigation_isRequired_is_stored_in_snapshot() b.HasIndex(""AlternateId"") .IsUnique(); - b.ToTable(""EntityWithTwoProperties""); + b.ToTable(""EntityWithTwoProperties"", ""DefaultSchema""); }); modelBuilder.Entity(""Microsoft.EntityFrameworkCore.Migrations.ModelSnapshotSqlServerTest+EntityWithTwoProperties"", b => @@ -6710,7 +6730,9 @@ partial class Snapshot : ModelSnapshot protected override void BuildModel(ModelBuilder modelBuilder) { #pragma warning disable 612, 618 - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder); @@ -6848,7 +6870,7 @@ protected override void BuildModel(ModelBuilder modelBuilder) b.HasKey(""Id""); - b.ToTable(""EntityWithManyProperties""); + b.ToTable(""EntityWithManyProperties"", ""DefaultSchema""); b.HasData( new @@ -7057,7 +7079,9 @@ protected override void BuildModel(ModelBuilder modelBuilder) protected virtual string GetHeading(bool empty = false) => @" - modelBuilder.HasAnnotation(""Relational:MaxIdentifierLength"", 128); + modelBuilder + .HasDefaultSchema(""DefaultSchema"") + .HasAnnotation(""Relational:MaxIdentifierLength"", 128); SqlServerModelBuilderExtensions.UseIdentityColumns(modelBuilder);" + (empty @@ -7107,6 +7131,7 @@ protected void Test(Action buildModel, string expectedCode, Action protected void Test(Action buildModel, string expectedCode, Action assert) { var modelBuilder = CreateConventionalModelBuilder(); + modelBuilder.HasDefaultSchema("DefaultSchema"); modelBuilder.HasChangeTrackingStrategy(ChangeTrackingStrategy.Snapshot); modelBuilder.Model.RemoveAnnotation(CoreAnnotationNames.ProductVersion); buildModel(modelBuilder);