Skip to content

Commit

Permalink
Merge pull request #31598 from dotnet-maestro-bot/merge/release/8.0-t…
Browse files Browse the repository at this point in the history
…o-main

[automated] Merge branch 'release/8.0' => 'main'
  • Loading branch information
msftbot[bot] authored Aug 31, 2023
2 parents 6d8c5a4 + 6a9f143 commit 8c2a0ba
Show file tree
Hide file tree
Showing 4 changed files with 63 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1379,13 +1379,16 @@ public static bool IsTableExcludedFromMigrations(this IReadOnlyEntityType entity
return excluded.Value;
}

if (entityType.BaseType != null)
if (entityType.BaseType != null
&& entityType.GetMappingStrategy() == RelationalAnnotationNames.TphMappingStrategy)
{
return entityType.GetRootType().IsTableExcludedFromMigrations();
}

var ownership = entityType.FindOwnership();
if (ownership is { IsUnique: true })
if (ownership is { IsUnique: true }
&& ownership.DeclaringEntityType.GetTableName() == entityType.GetTableName()
&& ownership.DeclaringEntityType.GetSchema() == entityType.GetSchema())
{
return ownership.PrincipalEntityType.IsTableExcludedFromMigrations();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -558,7 +558,7 @@ protected virtual IEnumerable<MigrationOperation> Diff(
DiffContext diffContext)
{
if (source.IsExcludedFromMigrations
&& target.IsExcludedFromMigrations)
|| target.IsExcludedFromMigrations)
{
// Populate column mapping
foreach (var _ in Diff(source.Columns, target.Columns, diffContext))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public async Task Should_throw_if_specified_region_is_wrong()
exception.Message);
}

[ConditionalFact(Skip = "Issue #runtime/issues/89118")]
[ConditionalFact]
public async Task Should_not_throw_if_specified_connection_mode_is_right()
{
var connectionMode = ConnectionMode.Direct;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8284,6 +8284,62 @@ public void Change_TPT_to_TPC_with_FKs_and_seed_data()
Assert.Equal(ReferentialAction.Cascade, operation.OnDelete);
}));

[ConditionalFact]
public void Change_TPT_to_TPC_with_excluded_base()
=> Execute(
common =>
{
common.Entity(
"Order",
x =>
{
x.ToTable("Order", t => t.ExcludeFromMigrations());
x.Property<int>("Id");
x.Property<string>("Address");
});
common.Entity(
"DetailedOrder",
x =>
{
x.ToTable("DetailedOrder");
x.HasBaseType("Order");
x.Property<string>("Description").HasColumnName("Description");
});
},
_ => { },
target =>
{
target.Entity("Order").UseTpcMappingStrategy();
},
upOperations =>
{
Assert.Equal(2, upOperations.Count);

var dropForeignKeyOperation = Assert.IsType<DropForeignKeyOperation>(upOperations[0]);
Assert.Null(dropForeignKeyOperation.Schema);
Assert.Equal("DetailedOrder", dropForeignKeyOperation.Table);
Assert.Equal("FK_DetailedOrder_Order_Id", dropForeignKeyOperation.Name);

var addColumnOperation = Assert.IsType<AddColumnOperation>(upOperations[1]);
Assert.Null(addColumnOperation.Schema);
Assert.Equal("DetailedOrder", addColumnOperation.Table);
Assert.Equal("Address", addColumnOperation.Name);
},
downOperations =>
{
Assert.Equal(2, downOperations.Count);

var dropColumnOperation = Assert.IsType<DropColumnOperation>(downOperations[0]);
Assert.Null(dropColumnOperation.Schema);
Assert.Equal("DetailedOrder", dropColumnOperation.Table);
Assert.Equal("Address", dropColumnOperation.Name);

var addForeignKeyOperation = Assert.IsType<AddForeignKeyOperation>(downOperations[1]);
Assert.Null(addForeignKeyOperation.Schema);
Assert.Equal("DetailedOrder", addForeignKeyOperation.Table);
Assert.Equal("FK_DetailedOrder_Order_Id", addForeignKeyOperation.Name);
});

[ConditionalFact]
public void Add_foreign_key_on_base_type()
=> Execute(
Expand Down

0 comments on commit 8c2a0ba

Please sign in to comment.