Skip to content

Commit

Permalink
fix: prevent duplicate key annotation in AdjustKey() (#883)
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewTriesToCode authored Oct 12, 2024
1 parent 4208149 commit f75ba2c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,13 @@ public MultiTenantEntityTypeBuilder AdjustKey(IMutableKey key, ModelBuilder mode
fk.SetProperties(fkProps, newKey!);
}

newKey?.AddAnnotations(annotations);
foreach (var annotation in annotations)
{
if (newKey?.FindAnnotation(annotation.Name) is null)
{
newKey?.AddAnnotation(annotation.Name, annotation.Value);
}
}

// remove key
Builder.Metadata.RemoveKey(key);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public void AdjustDependentForeignKeyOnAdjustAlternateKey()
}

[Fact]
public void PreserveAnnotations()
public void PreserveAnnotationsOnIndex()
{
using var db = GetDbContext(builder =>
{
Expand Down

0 comments on commit f75ba2c

Please sign in to comment.