Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/EFCore.Relational/Update/ModificationCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ private List<IColumnModification> GenerateColumnModifications()
}
}

if (_entries.Any(e => e.EntityType is { } entityType
if (!deleting && _entries.Any(e => e.EntityType is { } entityType
&& (entityType.IsMappedToJson()
|| entityType.GetFlattenedComplexProperties().Any(cp => cp.ComplexType.IsMappedToJson())
|| entityType.GetNavigations().Any(e => e.IsCollection && e.TargetEntityType.IsMappedToJson()))))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,30 @@ public virtual Task Remove_element_from_complex_collection_mapped_to_json()
}
});

[ConditionalFact]
public virtual Task Delete_complex_collection_owner_entity_mapped_to_json()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
CreateContext,
UseTransaction,
async context =>
{
var company = await context.Companies.SingleAsync(c => c.Id == 1);

context.Remove(company);

ClearLog();

await context.SaveChangesAsync();
},
async context =>
{
using (SuspendRecordingEvents())
{
var exists = await context.Companies.AnyAsync(c => c.Id == 1);
Assert.False(exists);
}
});

[ConditionalFact]
public virtual Task Modify_element_in_complex_collection_mapped_to_json()
=> TestHelpers.ExecuteWithStrategyInTransactionAsync(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ OUTPUT 1
""");
}

public override async Task Delete_complex_collection_owner_entity_mapped_to_json()
{
await base.Delete_complex_collection_owner_entity_mapped_to_json();

AssertSql(
"""
@p0='1'

SET IMPLICIT_TRANSACTIONS OFF;
SET NOCOUNT ON;
DELETE FROM [Companies]
OUTPUT 1
WHERE [Id] = @p0;
""");
}


public override async Task Modify_element_in_complex_collection_mapped_to_json()
{
await base.Modify_element_in_complex_collection_mapped_to_json();
Expand Down